Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How program label that drops down from top center like QProgressDialog does?
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.
so there won't be a button is not an option?
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.)
Not sure i ever saw that effect. Do you have a sample where it show this
"drop in" way?
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);
this->repaint(); // ensure progress is shown
// 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):
this->repaint(); // ensure progress is taken down
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
look at the "geometry" example.
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!
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. ;)
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.
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?
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.
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();
also look here
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 :)