Results 1 to 2 of 2

Thread: Sizes in construction - different behaviour Qt5 to Qt4 (example attached)

  1. #1
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Question Sizes in construction - different behaviour Qt5 to Qt4 (example attached)

    Hi,

    I've noticed a change in the way, sizes are set up in the construction process. With 4.7.0 I am able to get the final size of the app in MainWindow's constructor, with 5.2.1 this seems to have changed somehow.

    I've created a minimal, compileable example that demonstrates the difference by qDebug()ing the size information at various steps while constructing the QMainWindow. (--> see Attachments, there's also a screenshot of the different outputs): outputs in winmerge.jpg

    Please note that both source codes are identical apart from the "<QtWidgets/"-stuff in the #include-Sections.
    Both systems are set up in a Win7-environment, the 5.2.1 is running on a VM though. For now, I've tested this for Windows/MinGW.

    - Is this a bug or a "feature"? Shall I file a former, if it is one?
    - Is there a sensible workaround to obtain the final size already in the MainWindow constructor?

    It's actually workaroundable by calling all the initialisation stuff from the nth resizeEvent (for me: n=3) instead of from the constructor, but that seems to be a bit hacky for me.
    I am aware of this thread - so the conclusion is that the code shouldn't have worked in the first place, but just did?

    I am actually quite curious about what kind of underlying architecture change caused this behavioural difference..

    Sebastian
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Sizes in construction - different behaviour Qt5 to Qt4 (example attached)

    It is generally not advisable to rely on size() when the widget has not been shown yet.

    sizeHint() can come close provided no other effects influence the window's size (e.g. the windowing system resizing the window).

    size() usually has a good initial value when retrieved from showEvent() though.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    sedi (24th April 2014)

Similar Threads

  1. QGLWidget construction slow
    By ctgrund in forum Qt Programming
    Replies: 0
    Last Post: 16th June 2013, 13:31
  2. How to get printer name attached through LPT Port?
    By gurmeetsingh in forum Qt Programming
    Replies: 0
    Last Post: 20th April 2012, 15:18
  3. Replies: 4
    Last Post: 7th December 2011, 10:20
  4. Replies: 2
    Last Post: 1st April 2011, 17:37
  5. Number formatting for file name construction
    By philwinder in forum Qt Programming
    Replies: 1
    Last Post: 14th May 2008, 11:57

Tags for this Thread

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.