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. Multiple messages in QSplashScreen
Forum Updated to NodeBB v4.3 + New Features

Multiple messages in QSplashScreen

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 4.9k 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.
  • S Offline
    S Offline
    simplePlan
    wrote on last edited by
    #1

    I noticed that I can only show one message using 'showMessage' at a time. How can I show the application name and the status of the splashscreen at the same time without rendering a picture of the splashscreen including the application name. Here is my code so far:

    @
    QSplashScreen *splash = new QSplashScreen;
    QPixmap *splashPicture=new QPixmap(400,300);
    splashPicture->fill(Qt::lightGray);
    splash->setPixmap(*splashPicture);
    splash->show();

    Qt::Alignment center = Qt::AlignHCenter | Qt::AlignVCenter;
    splash->showMessage(QObject::tr("Application 1.0"),
                        center, Qt::black);
    
    Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
    splash->showMessage(QObject::tr("Setting up the main window..."),
                       topRight, Qt::black);
    

    @

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      Either add a label to QSlashScreen (e.g. by subclassing) or just create your own splash screen dialog with QtDesigner. I Recommend the latter method, because a custom splash screen should be set up within a few minutes from scratch.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        simplePlan
        wrote on last edited by
        #3

        Thank you for your advice. I even found a more comfortable method (using QPainter) to do it, by replacing lines 7-9 by:

        @
        QPainter* painter=new QPainter(splashPicture);
        painter->drawText(200,150,"Application 1.0");
        @

        The problem is now resolved for me.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on last edited by
          #4

          Oh, I thought by saying
          "without rendering a picture of the splashscreen including the application name"
          You meant you don't want to do it by painting on the splash pixmap.

          Anyhow, make sure to delete the painter, or you'll get a memory leak. Better yet, create it on the stack via

          QPainter painter(&splashPicture);

          1 Reply Last reply
          0
          • S Offline
            S Offline
            simplePlan
            wrote on last edited by
            #5

            Thanks. Well, I am a beginner, I might not express myself too well. I wanted to say, I dont want to do it in a graphic software outside Qt, so I can easily change it when I want to modify the title.

            1 Reply Last reply
            0
            • E Offline
              E Offline
              elmigranto
              wrote on last edited by
              #6

              Pretty general approach with layouts works here too:

              @ QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8("splashscreen.png")));

              QVBoxLayout *layout = new QVBoxLayout(splash);
              layout->setAlignment(Qt::AlignCenter);
              
              QLabel *label1 = new QLabel(QString::fromUtf8("Hello, World"), splash);
              QLabel *label2 = new QLabel(QString::fromUtf8("I'm loading…"), splash);
              layout->addWidget(label1);
              layout->addWidget(label2);
              
              splash->setLayout(layout);
              splash->show();
              
              // do stuff...
              
              splash->hide();
              splash->deleteLater();@
              
              1 Reply Last reply
              1

              • Login

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