各位大侠:
小弟用qte4.5.0,但就是设置不了widget的背景图片。希望高手指点。
代码如下:
#include <qapplication.h>
#include <qpixmap.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qtextedit.h>
#include <qlayout.h>
int main( int argc, char ** argv )
{
  QApplication app(argc, argv);
    QWidget *w = new QWidget(0);
   w->setAutoFillBackground(true);
   QPalette palette2;
   palette2.setBrush(QPalette::Window, QBrush(QPixmap("logo.png")));
   palette2.setBrush(QPalette::Base, QBrush(QPixmap("logo.png")));
  w->setPalette(palette2);
 QVBoxLayout *lout = new QVBoxLayout(w);
 QTextEdit* edit = new QTextEdit( );
  QLabel* label = new QLabel( "This is a transparent label" );
  QCheckBox* cb = new QCheckBox( "Check me" );
  lout->addWidget(edit);
 lout->addWidget(label);
  lout->addWidget(cb);
  w->show();
 QObject::connect( &app, SIGNAL( lastWindowClosed() ),
                   &app, SLOT( quit() ) );
  return app.exec();
}