Could you explain that loop thing again? Maybe a screenshot is needed?
Could you explain that loop thing again? Maybe a screenshot is needed?
I can't post screenshots, sorry
1) I have an implementation class <A>, that herits from QDialog.
This class create a QDialog that contains some text, a QTableWidget en 2 buttons.
The QTableWidget is updated, anf filled with some data (e-mails).
I have reimplemented the showEvent() en resizeEvent() in order :
- to fit the QDialog (and it's QTableWidget) to the content
- to adjust the QTableWidget size (and content display) when the user resize the QDialog
2) In my application, I've a loop that creates <A> objects and give them some data : 1 cycle of loop by e-mail account.
Immediatly, each <A> object will be auto-resized to fit to its content.
My application store the <A> objects in a QList<A> *.
3) I show thoses <A> objects.
4) I want all <A> objects to have the same width.
I look at each one, store the max width, and resize all the <A> objects to the max widt I've found. Like the <A> objects are visible, this works well.
5) I want a best display of my <A> objects : a Windows cascade style is nice.
So I move them, using the setGeometry(int, int, int, int) function. Like the <A> objects are visible, this works well.
Now I would like to do the same job, but the <A> objects would be hidden.
Like they are hidden, the moveEvent() and resizeEvent() are managed by Qt, but the documentation says that :
So, I do the same job, but I don't show the <A> objects.If the widget is not currently visible, it is guaranteed to receive appropriate events before it is shown.
At the end of the job, after the 5) point, I show them : they have been moved correctly, but not resized ike they should have been...
I will simply reuse the showEvent.
Simply holds position and size data in variables.
When I enter the showEvent, if those data aren't equals to 0, I'll use them and set variables to 0.
I would use the sizeHint() to force the dialog to a proper width. If you change the sizeHint() and apply a constraint on the layout of the widget (dialog, in your case), Qt will make sure it is sized properly. Then it doesn't matter if the widget is hidden or not - it'll get resized when needed.
Thanks for the tip Wysota, but I'll stay on my showEvent solution. I'm not sure about that the sizeHint will works correctly... Resize should work too, but it doesn't![]()
Bookmarks