Results 1 to 6 of 6

Thread: Hidden QDialog : force the update() or repaint()

  1. #1
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Hidden QDialog : force the update() or repaint()

    Hi,

    I've some Qdialogs generated in a loop. The implementation class of the QDialogs resize them to fit the content.
    Each QDialog is shown.

    At the end of the loop I want them to have the same width.
    So, each of them give me his width, and I resize them to the width max unsing resize(int, int).

    After that, I want them to be displayed in Windows cascade style : each QDialog must be just under the previous (small padding bottom and small paddin right)... And I do this using setGeometry(int, int, int, int).

    That's ok : everything works well.
    Now I don't show the QDialogs in the loop : the user won't understand why his frames are resized and moved on the screen... So I let them hidden during the work.
    At the end a show each of them, but they are no more resized .

    Reading the documentation, I understood that the update() and repaint() slots aren't used if the widget is hdden... But they add :
    If the widget is not currently visible, it is guaranteed to receive an event before it is shown.
    The problem is that my moveEvent seems to be received, but not the resizeEvent().

    Is there a solution to hide them, work on their size/position, and show them correctly ?

    PS : I've already reimplemented the show()/resize() events of the QDialogs ine the implementation class, in order that they automaticaly adjust the frame to the content, or the content to the frame if it is resized by the user.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hidden QDialog : force the update() or repaint()

    Could you explain that loop thing again? Maybe a screenshot is needed?

  3. #3
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hidden QDialog : force the update() or repaint()

    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 :
    If the widget is not currently visible, it is guaranteed to receive appropriate events before it is shown.
    So, I do the same job, but I don't show the <A> objects.
    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...

  4. #4
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hidden QDialog : force the update() or repaint()

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Hidden QDialog : force the update() or repaint()

    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.

  6. #6
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hidden QDialog : force the update() or repaint()

    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

Similar Threads

  1. nmake problems while building mysql driver
    By MarkoSan in forum Installation and Deployment
    Replies: 27
    Last Post: 25th May 2007, 13:57
  2. force repaint
    By georgie in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2006, 14:16
  3. QT4 beginner Fatal Error
    By Remyfr in forum Installation and Deployment
    Replies: 3
    Last Post: 11th March 2006, 02:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.