[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);
    QTimer::singleShot(3000, &splashScr ,SLOT(close()));
    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

  • Moderators

  • 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();
    painter.drawImage(scaledRect, scaled);
    QPixmap Logo;
    QSplashScreen splashScrWindow (viewer, Logo, Qt::WindowStaysOnTopHint);
    QTimer::singleShot(3000, &splashScrWindow ,SLOT(close()));
    return app.exec();

    its basically what is done during the resizeEvent(..) in the FAQ link Eddy posted.

  • Moderators

    thanks for sharing your solution!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.