#include <QtGui>
int main (int argc, char **argv)
{
QPixmap *p1
=new QPixmap(p
->scaled
( 30,
20, Qt
::IgnoreAspectRatio, Qt
::SmoothTransformation ));
brush.setStyle(Qt::TexturePattern);
brush1.setStyle(Qt::SolidPattern);
w.setPalette(palBack);
lab->setGeometry(30,30,40,30);
lab->setPalette(palBack);
lab->setAutoFillBackground (true);
w.show();
w.setFixedSize(300,200);
return app.exec();
}
#include <QtGui>
int main (int argc, char **argv)
{
QApplication app(argc,argv);
QWidget w;
QPixmap *p=new QPixmap("plane.jpg");
QPixmap *p1=new QPixmap(p->scaled ( 30,20, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ));
QPalette palBack;
QBrush brush(*p1);
brush.setStyle(Qt::TexturePattern);
palBack.setBrush(QPalette::Active, QPalette::Button, brush);
palBack.setBrush(QPalette::Inactive, QPalette::Button, brush);
palBack.setBrush(QPalette::Active, QPalette::Window, brush);
palBack.setBrush(QPalette::Inactive, QPalette::Window, brush);
QBrush brush1(QColor(255, 255, 255, 255));
brush1.setStyle(Qt::SolidPattern);
palBack.setBrush(QPalette::Disabled, QPalette::Button, brush1);
palBack.setBrush(QPalette::Disabled, QPalette::Window, brush1);
w.setPalette(palBack);
QPushButton *lab=new QPushButton(&w);
lab->setGeometry(30,30,40,30);
lab->setPalette(palBack);
lab->setAutoFillBackground (true);
w.show();
w.setFixedSize(300,200);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
By using above I am getting the black push button in spite of "plane.jpg". However It is working well for QWidget background. Any help or advice is highly respected.
Bookmarks