我是QT的初學者,我們在寫繪圖方面的小程式,可是我們遇到一個瓶頸,不管怎樣圖形就是不會顯示出來,可以請大大幫我們看看我們是那個地方有錯嗎?!以下是我們的程式碼。。。。
#include <qwidget.h>
#include <qpainter.h>
#include <qapplication.h>
#include <qlabel.h>
#include <qpushbutton.h>
class DrawView : public QWidget
{
public:
DrawView();
public slots:
protected:
private:
QPrinter *printer;
};
DrawView::DrawView()
{
setBackgroundColor( white );
QLabel* mylabel = new QLabel("Hello !!", this );
mylabel->resize (80,30);
QPainter painter;
painter.begin(this);
painter.setBrush( Qt::green );
painter.setPen( Qt::blue );
painter.drawEllipse( 250, 10, 200, 100 );
painter.end();
QPushButton* mybutton = new QPushButton("Quit", this );
mybutton->setGeometry (10,50,100,30);
QObject::connect(mybutton, SIGNAL(clicked()), SLOT(quit()));
}
int main(int argc, char* argv[])
{
QApplication myapp(argc, argv);
DrawView* mywidget = new DrawView();
mywidget->setGeometry(300, 250, 500, 400);
myapp.setMainWidget( mywidget );
mywidget->show();
return myapp.exec();
}