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. Add styles to a QMessageBox
Forum Updated to NodeBB v4.3 + New Features

Add styles to a QMessageBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 5 Posters 2.0k Views 3 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi
    It will react to stylesheets but i doubt you can center text.
    You could make your own based on QDialog so it could any way you like.
    Its not much work since you seem not to use any icons or buttons :)

    M 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi,

      Since it looks it's happening at application startup, I would go with QSplashScreen.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      3
      • SGaistS SGaist

        Hi,

        Since it looks it's happening at application startup, I would go with QSplashScreen.

        M Offline
        M Offline
        maria.v
        wrote on last edited by
        #4

        @SGaist Unfortunately it doesn't happen at startup. it happens in 3 moment after triggering some button

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #5

          Well, you can still use it there. Or a QProgressDialog with an infinite progress bar.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          M 1 Reply Last reply
          1
          • mrjjM mrjj

            Hi
            It will react to stylesheets but i doubt you can center text.
            You could make your own based on QDialog so it could any way you like.
            Its not much work since you seem not to use any icons or buttons :)

            M Offline
            M Offline
            maria.v
            wrote on last edited by
            #6

            @mrjj I tried doing something like msgBox.setStylesheet("color: red;") but it didn't respond. Can you explain the other option a little more? Thanks

            mrjjM 1 Reply Last reply
            0
            • SGaistS SGaist

              Well, you can still use it there. Or a QProgressDialog with an infinite progress bar.

              M Offline
              M Offline
              maria.v
              wrote on last edited by
              #7

              @SGaist I tried first with the progress bar but I have no way to fill it, and leaving it empty also looks bad.
              Screen Shot 2020-04-29 at 15.22.47.png

              SGaistS 1 Reply Last reply
              0
              • M maria.v

                @mrjj I tried doing something like msgBox.setStylesheet("color: red;") but it didn't respond. Can you explain the other option a little more? Thanks

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #8

                @maria-v
                Hi
                Try
                msgBox.setStyleSheet("background-color: rgb(255, 0, 0);");
                and it should turn red.

                Both QSplashScreen and QProgressDialog would also be good options as @SGaist mentions.

                What i was talking about was a UI form QDialog made with the wizard.
                alt text
                alt text
                and you get a new UI where you can add a label or other elements to make it look 100% as you wish.
                alt text

                alt text

                1 Reply Last reply
                0
                • M maria.v

                  @SGaist I tried first with the progress bar but I have no way to fill it, and leaving it empty also looks bad.
                  Screen Shot 2020-04-29 at 15.22.47.png

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @maria-v said in Add styles to a QMessageBox:

                  @SGaist I tried first with the progress bar but I have no way to fill it, and leaving it empty also looks bad.
                  Screen Shot 2020-04-29 at 15.22.47.png

                  If you put the same value for min and Max, you'll have an infinite bar.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  M 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    @maria-v said in Add styles to a QMessageBox:

                    @SGaist I tried first with the progress bar but I have no way to fill it, and leaving it empty also looks bad.
                    Screen Shot 2020-04-29 at 15.22.47.png

                    If you put the same value for min and Max, you'll have an infinite bar.

                    M Offline
                    M Offline
                    maria.v
                    wrote on last edited by
                    #10

                    @SGaist said in Add styles to a QMessageBox:

                    infinite bar

                    What do you call "infinite bar"? I tried progress.setMinimum(0); progress.setMaximum(0); progress.setValue(0); and in Windows got
                    Captura (1).PNG

                    S 1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      Bonnie
                      wrote on last edited by
                      #11

                      Cann't you just use a QLabel to do that?
                      I'm using a QLabel showing "Loading" when the ui is loading for seconds.
                      Seems you don't need any interactive functions.
                      And it is easy to be customized with stylesheet.

                      1 Reply Last reply
                      0
                      • M maria.v

                        @SGaist said in Add styles to a QMessageBox:

                        infinite bar

                        What do you call "infinite bar"? I tried progress.setMinimum(0); progress.setMaximum(0); progress.setValue(0); and in Windows got
                        Captura (1).PNG

                        S Offline
                        S Offline
                        SimonSchroeder
                        wrote on last edited by
                        #12

                        @maria-v said in Add styles to a QMessageBox:

                        What do you call "infinite bar"? I tried progress.setMinimum(0); progress.setMaximum(0); progress.setValue(0); and in Windows got

                        I know this as "pulsing progress bar". However, you need to process incoming events occasionally in order to have that pulsating bar. The easiest (though not the preferred way) is to put QApplication::processEvents() in several places which will allow the progress dialog to update.

                        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