#include <QApplication>
#include <QWidget>
#include <QPixmap>
#include <QPainter>
#include <QPaintEvent>
{
public:
protected:
};
MyWidget
::MyWidget(QWidget *parent
)
{
setFixedSize( mPixmap.size() );
}
{
if( !mPixmap.isNull() )
{
p.drawPixmap( 0, 0, mPixmap );
}
}
int main(int argc, char *argv[])
{
MyWidget widget;
widget.show();
return app.exec();
}
#include <QApplication>
#include <QWidget>
#include <QPixmap>
#include <QPainter>
#include <QPaintEvent>
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent = 0);
QPixmap mPixmap;
protected:
virtual void paintEvent( QPaintEvent* );
};
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
mPixmap = QPixmap( "k8055.jpg" );
setFixedSize( mPixmap.size() );
}
void MyWidget::paintEvent( QPaintEvent* e )
{
if( !mPixmap.isNull() )
{
QPainter painter( this );
p.drawPixmap( 0, 0, mPixmap );
}
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyWidget widget;
widget.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks