main
- C/C++ code
int main(int argc, char *argv[]){ QApplication a(argc, argv); //设置编码,显示中文 QTextCodec::setCodecForTr( QTextCodec::codecForName("GB2312") ); COrderComm oOdCm; oOdCm.showMaximized(); return a.exec();}
COrderComm.h
- C/C++ code
COrderComm::COrderComm(QWidget *parent) : QMainWindow(parent) { //这里如何加在背景图片啊 }
图片在当前工程images文件夹下 bg.png,大小是(360×480),模拟器用的是s60 5th
------解决方案--------------------
- C/C++ code
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); QPalette palette; palette.setBrush(QPalette::Background, QBrush(QPixmap("1.jpg"))); this->setPalette(palette);}