我昨天那个还是不能正常显示图像,我的代码是这样,里面加了你说的那两个函数,帮看看
#include <QApplication>
#include <QFont>
#include <QWSServer>
#include <QPushButton>
#include <QPalette>
#include <QDesktopWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv, QApplication::GuiServer);
//app.setGeometry(0,0,900,700);
QPalette palette;
QBrush *BackColor = new QBrush(QColor(58,110,160)); //设置背景颜色
QWSServer::setBackground(*BackColor); //应用背景颜色
palette.setColor(QPalette::Active,static_cast <QPalette::ColorRole>(1),QColor(255,0,0));
QPushButton quit("Quit");
quit.setPalette(palette);
quit.setAutoFillBackground(true);
int screenWidthM=app.desktop()->size().width();
int screenHeightM=app.desktop()->size().height();
quit.setGeometry(0,0,screenWidthM,screenHeightM);
quit.setFont(QFont("Times", 18, QFont::Bold));
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
quit.show();
app.exec();
return 0;
}
这样运行后还是 出下鼠标,然后绿屏....