Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]Easiest way to set image to NOT auto repeat ?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Easiest way to set image to NOT auto repeat ?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 4.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KA51O
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      have a look at "this FAQ":http://developer.qt.nokia.com/faq/answer/when_setting_a_background_pixmap_for_a_widget_it_is_tiled_if_the_pixmap_is_

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • K Offline
        K Offline
        KA51O
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          KA51O
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #5

            thanks for sharing your solution!

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved