QProgressDialog: doesn't "relayout" when showing?
-
sorry, i'm still new to this, so code fragments are more opaque to me than you might expect.
i have a QProgressDialog that i am NOT overriding, ie: i'm using it without subclassing it. the entire contents of the dialog need to be re-laid out, not just one widget. how do i do that? i also don't know what a statuswidget is
-
@davecotter said in QProgressDialog: doesn't "relayout" when showing?:
i have a QProgressDialog that i am NOT overriding, ie: i'm using it without subclassing it.
This is fine, no reason to subclass if you don't need to.
the entire contents of the dialog need to be re-laid out, not just one widget. how do i do that?
Is it made in the designer? If so could you screenshot the object tree from the designer (right side) and say which widget you're hiding?
i also don't know what a statuswidget is
That's a custom widget I wrote for a project. I pasted the code as an illustration only. The widget is hidden/shown based on some unimportant condition. The point is that the dialog that holds it, however, doesn't resize properly if I don't call
updateGeometry
on this child widget. As I said, I believe this is a bug in the layout/widget system, where the geometry change isn't completely propagated up through the object tree. -
@davecotter
I‘ve run into this as well.Am I right in the assumption, that you call resize or setGeometry on your ProgressDialog and eventually show?
Simply call show first and set the geometry/size afterwards.
Should fix the issue.
-
Is it made in the designer?
no it's
QProgressDialog
Simply call show first and set the geometry/size afterwards
i did attempt to call
qDialog.show()
and then callqDialog.updateGeometry()
, that didn't help, it still showed with wrong geometry. -
@davecotter said in QProgressDialog: doesn't "relayout" when showing?:
no it's QProgressDialog
Humor me, will you?
QCoreApplication::postEvent(progressDialog, new QEvent(QEvent::StyleChange));
where
progressDialog
is a pointer to your dialog. Does this work?
I saw many a thing in the source and almost none was even remotely appealing ... -
calling that after calling
show()
does nothing. even after callingshow()
thenQApplication::processEvents()
, still nothing. only AFTER the window is already on the screen (showing bogus geometry) does this call do anything (and yes it corrects the geometry), but doing it this way causes ugly visual flickerwhat gives? how me fixy? layout should work even when the window is still hidden.
-
@davecotter
Ok, I'm kind uncomfortable suggesting this...You could, as a work around, position your progressDialog way of screen, resize it and move it to the position i'ts supposed to be.
It's ugly, it's hacky but it should remove the flickering issue. However it will not solve the underlying issue.
To you happen to have a minimal workable example ?
-
@davecotter said in QProgressDialog: doesn't "relayout" when showing?:
how me fixy?
Well, my best guess now is to wait for the polish event (with an event filter) and post the style change event into the event loop. Bad and ugly.
layout should work even when the window is still hidden.
Yes, if the progress dialog used a
QLayout
, which it doesn't. It recalculates its own children's positions, it's a big mess in there ... -
okay the problem was my hiding the cancel button with
i_qDlg.setCancelButton(NULL);
i guess i expected that to cause a relayout of the geometry, or post a styleChange event, but alas no.
so all i did was then immediately call
QCoreApplication::postEvent(i_qDlg, new QEvent(QEvent::StyleChange));
and all is well.thanks all for the hints and tips! (this actually sounds like a bug but whatever)
-dave
-
@davecotter said in QProgressDialog: doesn't "relayout" when showing?:
this actually sounds like a bug
Almost certainly, yes.