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. How program label that drops down from top center like QProgressDialog does?
Forum Updated to NodeBB v4.3 + New Features

How program label that drops down from top center like QProgressDialog does?

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 2 Posters 2.6k 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.
  • B Offline
    B Offline
    buckler
    wrote on last edited by
    #1

    Hello,
    I have successfully used a QProgressDialog using the following initializer:
    QProgressDialog progress("Text", 0, 100, this);

    It presents by nicely "dropping" down from the center / top of my main window.

    Now, I would like to create a temporary informational label for the user. Unlike the progress dialog, there is no "cancel" button, or any button for that matter. But, I very much like the style in which the progress dialog drops down on the window, and I would like to use that for my informational label. However, I ahve tried with a number of attempts, with variations on QDialog, QLabel, and even QStatusBar but none of them look like the one I like.

    I also tried to look at the source code for QProgressDialog itself; but the coding style has various conventions that make it hard for me to understand how to replicate the required parts without the button behaviour.

    Help?

    Thank you,
    Andy

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      hi
      and using
      http://doc.qt.io/qt-5.5/qprogressdialog.html#setCancelButton
      setCancelButton(0);
      so there won't be a button is not an option?

      1 Reply Last reply
      0
      • B Offline
        B Offline
        buckler
        wrote on last edited by
        #3

        Thank you, I see that is a why to avoid the cancel button, but for me to be more clear: I don't need/want the progress bar itself, either! What I like about the QProgressBar is its display behavior vis-a-vis the way it "drops" down gently from the top, and later recedes from whence it came, not the content itself. (My content will be a simple text string.)

        mrjjM 1 Reply Last reply
        0
        • B buckler

          Thank you, I see that is a why to avoid the cancel button, but for me to be more clear: I don't need/want the progress bar itself, either! What I like about the QProgressBar is its display behavior vis-a-vis the way it "drops" down gently from the top, and later recedes from whence it came, not the content itself. (My content will be a simple text string.)

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

          @buckler
          Ok :)
          Not sure i ever saw that effect. Do you have a sample where it show this
          "drop in" way?

          1 Reply Last reply
          0
          • B Offline
            B Offline
            buckler
            wrote on last edited by
            #5

            Here is my code that has the effect of the dropping and receding (of course this is for a progress indicator rather than the label I am presently looking for):

            @
            QProgressDialog progress("Preloading targets from list...", "Cancel", 0, 100, this);
            progress.setWindowModality(Qt::WindowModal);
            progress.setMinimumDuration(1000);
            progress.setValue(8);
            this->repaint(); // ensure progress is shown
            qApp->processEvents();
            ...
            // and then sometime later at the point at which I want it to go away. A label wouldn't go away like this, but the example):
            progress.setValue(100);
            this->repaint(); // ensure progress is taken down
            qApp->processEvents();
            @

            mrjjM 1 Reply Last reply
            0
            • B buckler

              Here is my code that has the effect of the dropping and receding (of course this is for a progress indicator rather than the label I am presently looking for):

              @
              QProgressDialog progress("Preloading targets from list...", "Cancel", 0, 100, this);
              progress.setWindowModality(Qt::WindowModal);
              progress.setMinimumDuration(1000);
              progress.setValue(8);
              this->repaint(); // ensure progress is shown
              qApp->processEvents();
              ...
              // and then sometime later at the point at which I want it to go away. A label wouldn't go away like this, but the example):
              progress.setValue(100);
              this->repaint(); // ensure progress is taken down
              qApp->processEvents();
              @

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

              @buckler
              Hmm, i tried the code in a button on mainform but
              the dialog just flashes and is gone. so not sure what the effect is. sorry
              You can animate using
              http://doc.qt.io/qt-5.5/animation-overview.html
              look at the "geometry" example.

              1 Reply Last reply
              0
              • B Offline
                B Offline
                buckler
                wrote on last edited by
                #7

                Sorry, just sleep for as long as you like in between the two progress.setValue calls... or do any other program action that holds it up before setting the 100 value is what takes it down!

                mrjjM 1 Reply Last reply
                0
                • B buckler

                  Sorry, just sleep for as long as you like in between the two progress.setValue calls... or do any other program action that holds it up before setting the 100 value is what takes it down!

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

                  @buckler
                  well i just made button on mainwin and

                  QProgressDialog progress("Preloading targets from list...", "Cancel", 0, 100, this);
                  progress.setWindowModality(Qt::WindowModal);
                  progress.setMinimumDuration(1000);
                  progress.setValue(8);
                  this->repaint(); // ensure progress is shown
                  qApp->processEvents();
                  

                  in there but for some reason, it not really staying up. ;)

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    buckler
                    wrote on last edited by
                    #9

                    Is the function you are calling it from closing? That would take it away regardless of its value of course. It needs to stay in scope to be displayed, and without setting its value to 100.

                    mrjjM 1 Reply Last reply
                    0
                    • B buckler

                      Is the function you are calling it from closing? That would take it away regardless of its value of course. It needs to stay in scope to be displayed, and without setting its value to 100.

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

                      @buckler
                      yes please shoot me, i made THE noob trick,
                      allocated on stack, gone when function ends...
                      Ok, so is this the fade in effect ?
                      Like open softly?

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

                        Do you see it smoothly descend when created, connected (not floating) to top of window, and then when it goes away, it glides up as if into the bar again? If this is the screen effect you see, that's what I want my label to do.

                        mrjjM 1 Reply Last reply
                        0
                        • B buckler

                          Do you see it smoothly descend when created, connected (not floating) to top of window, and then when it goes away, it glides up as if into the bar again? If this is the screen effect you see, that's what I want my label to do.

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

                          @buckler
                          Ok that sounds so very cool. mine just pop up in center of mainwin.
                          What platform are you on?
                          (win 7 here)
                          If its mac, then any dialog based widget should also slide.
                          If you create empty dialog and show it, will it also slide?
                          it must have parent set to mainwindow (or window where it should slide from)
                          and be modal. And use show() , not exec();
                          Update:
                          also look here
                          https://doc.qt.io/archives/qq/qq18-macfeatures.html
                          seems like Qt::Drawer is what you are after.
                          Sorry for being a bit thick. Didn't know QProgressDialog would have
                          cool effects on other platforms :)

                          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