Results 1 to 2 of 2

Thread: Need to know widget size before first shown

  1. #1
    Join Date
    Oct 2006
    Location
    Germany
    Posts
    84
    Thanks
    5
    Thanked 5 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Need to know widget size before first shown

    Hello,
    I have a couple of dialogs which I need to position very directly. The problem is, that QWidget::height() etc. won't give me the real sizes unless QWidget::show() was called once.
    I've looked through the doc and didn't seem to find some function which actually lays out all the widgets in the dialog before QWidget::show() is called.
    My current workaround for this is:
    Qt Code:
    1. this->show();
    2. this->move(x, y);
    To copy to clipboard, switch view to plain text mode 
    But that is not nice since you can see the dialog for tiny time at some position at the screen and then in suddenly moves to my x- and y-coordinates. I don't like it
    So, have I overlooked the function I need or is there maybe some other, nicer, workaround for this?
    Thank you!

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

    Default Re: Need to know widget size before first shown

    No, there is none. You can either try to guess the size based on the sizeHint() (but the window decoration will screw things up and furthermore you don't have any assurance the widget will have size equal to its hint) or use layouts to position the widget. If the standard ones don't suit your needs - implement your own.

Similar Threads

  1. Replies: 4
    Last Post: 10th December 2006, 09:04
  2. Pin/Unpin Dock Widget
    By charlesD in forum Newbie
    Replies: 1
    Last Post: 21st June 2006, 06:57
  3. Size of a plugin widget in designer
    By high_flyer in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2006, 13:29
  4. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14
  5. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16

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.