我在QSplashScreen
的构造函数中创建一个QMainWindow
:
MainApp::MainApp() : QMainWindow(),
splashScreen(new QSplashScreen)
{
splashScreen->setFixedSize(350, 120);
//splashScreen->move(splashScreen->x()-175, splashScreen->y()-60); //inits with upperleft corner at screen center
splashScreen->setWindowOpacity(0.85);
splashScreen->setAttribute(Qt::WA_StyledBackground);
splashScreen->setStyleSheet("QSplashScreen { background-color: #000;"
"background-image: url('"+pathLogo+"');"
"background-repeat: no-repeat;"
"background-position: center;"
"border: 2px solid #fac805; }");
QLabel *vrsLbl = new QLabel(splashScreen);
vrsLbl->resize(350, 13);
vrsLbl->move(0, 80);
vrsLbl->setPixmap(pxVersion);
vrsLbl->setAlignment(Qt::AlignHCenter);
splashScreen->show();
}
显示的初始屏幕的左上角在屏幕中心。如上所述,一种简单的解决方法是移动它(因为它的大小已知)。
根据the docs:
初始屏幕出现在屏幕中央。
那这里出了什么问题?
答案 0 :(得分:1)
我可能已经太快了,无法将其发布为问题。
经过一些测试,我发现QSplashScreen
QPixmap
为空时显然没有居中。