You only have to change one line... clearly too hard:
#include <QtGui>
#include <QDebug>
Q_OBJECT
public:
// setStyleSheet( "Frame{ background: blue }" );
setStyleSheet( "Frame{ background-image: url(plasma.png); }" );
}
protected:
p.drawLine( rect().topLeft(), rect().bottomRight() );
p.drawText( rect().center(), "works!" );
}
};
int main(int argc, char *argv[])
{
Frame m;
m.show();
return app.exec();
}
#include "main.moc"
#include <QtGui>
#include <QDebug>
class Frame : public QFrame{
Q_OBJECT
public:
Frame( QWidget * parent = NULL ) : QFrame(parent){
// setStyleSheet( "Frame{ background: blue }" );
setStyleSheet( "Frame{ background-image: url(plasma.png); }" );
}
protected:
void paintEvent( QPaintEvent * event ){
QFrame::paintEvent(event);
QPainter p(this);
p.drawLine( rect().topLeft(), rect().bottomRight() );
p.drawText( rect().center(), "works!" );
}
};
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Frame m;
m.show();
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
and it looks like:
simple_example.jpg
with a 64x64 tile background.
If you do not share the errors then you cannot expect corrections.
Bookmarks