[SOLVED]Easiest way to set image to NOT auto repeat ?
-
Hi everyone,
I got a QSplashScreen I want to display before an application starts. My question is how can I set the image to not auto repeat?
@QApplication app(argc, argv);
QMainWindow* viewer = new QMainWindow();
QPixmap Logo (":/Logo.png");
QSplashScreen splashScr (viewer, Logo, Qt::WindowStaysOnTopHint);
splashScr.showFullScreen();
QTimer::singleShot(3000, &splashScr ,SLOT(close()));
viewer->show();
return app.exec();@
Do I have to use a QLayout or a Qt Style Sheet or is there a simple way like maybe @splashScr.getLayout()->setAutoRepeatBackground(false);@ ?Also when I dont use splashScr.showFullScreen() but instead use splashScr.show() the splashscreen is not raised. Any hints on that?
Thanks in advance
-
-
So basically I have to write my own QSplashScreen inherited class and rewrite the resizeEvent(..) just to achieve this simple layout task?
Thats sad.
Still thanks for the hint Eddy. Sorry that I didn't find this FAQ entry with my search.
-
Since my QSplashScreen only shows once during start up and there is no resizeEvent to catch, I just did this :
@int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QMainWindow* viewer = new QMainWindow();
QImage splashScrImage (":/Logo_big.png");
QSize screenSize = QApplication::desktop()->geometry().size();
QImage splashScr (screenSize, QImage::Format_ARGB32_Premultiplied);
QPainter painter (&splashScr);
painter.fillRect(splashScr.rect(), Qt::black);
QImage scaled = splashScrImage.scaled(screenSize, Qt::KeepAspectRatio);
QRect scaledRect = scaled.rect();
scaledRect.moveCenter(splashScr.rect().center());
painter.drawImage(scaledRect, scaled);
QPixmap Logo;
Logo.convertFromImage(splashScr);
QSplashScreen splashScrWindow (viewer, Logo, Qt::WindowStaysOnTopHint);
splashScrWindow.move(0,0);
splashScrWindow.show();
QTimer::singleShot(3000, &splashScrWindow ,SLOT(close()));
viewer->show();
return app.exec();
}@its basically what is done during the resizeEvent(..) in the FAQ link Eddy posted.
-
thanks for sharing your solution!