#include <qapplication.h>
#include <qfont.h>
#include <qpainter.h>
#include <qwidget.h>
{
public:
protected:
p.setPen( Qt::blue );
p.fillRect( 0, 0, width(), height(), Qt::cyan );
p.drawText( 20, 20, "Hello" );
}
};
int main( int argc, char **argv )
{
Test t;
t.show();
QObject::connect( qApp,
SIGNAL( lastWindowClosed
() ),
qApp, SLOT( quit() ) );
return app.exec();
}
#include <qapplication.h>
#include <qfont.h>
#include <qpainter.h>
#include <qwidget.h>
class Test : public QWidget
{
public:
Test( QWidget *parent = 0 ) : QWidget( parent ) {}
protected:
void paintEvent( QPaintEvent * ) {
QPainter p( this );
p.setPen( Qt::blue );
p.setFont( QFont( "Courier", 14, QFont::Bold ) );
p.fillRect( 0, 0, width(), height(), Qt::cyan );
p.drawText( 20, 20, "Hello" );
}
};
int main( int argc, char **argv )
{
QApplication app( argc, argv );
Test t;
t.show();
QObject::connect( qApp, SIGNAL( lastWindowClosed() ),
qApp, SLOT( quit() ) );
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks