Results 1 to 6 of 6

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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?

  2. #2
    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...

  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 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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 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.

  5. #5
    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, 12:57
  2. force repaint
    By georgie in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2006, 13:16
  3. QT4 beginner Fatal Error
    By Remyfr in forum Installation and Deployment
    Replies: 3
    Last Post: 11th March 2006, 01: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
  •  
Qt is a trademark of The Qt Company.