gpt4 book ai didi

c++ - 为什么 QSplashScreen 在显示时不居中?

转载 作者:行者123 更新时间:2023-11-30 03:20:01 24 4
gpt4 key购买 nike

我在 QMainWindow 的构造函数中创建了一个 QSplashScreen:

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 :

The splash screen appears in the center of the screen.

那么这里出了什么问题呢?

最佳答案

我可能有点太快了,无法将其作为问题发布。

经过一些测试后,我发现当 QSplashScreen 有一个空的 QPixmap 时,它显然不会居中。

关于c++ - 为什么 QSplashScreen 在显示时不居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53193027/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com