Results 1 to 6 of 6

Thread: Size Difference

  1. #1
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Size Difference

    Hi, I'm just wondering why there is a size difference between a widget in a window

    e.g. in design viewer it's 600 x 450

    and when I write this->width(); and this->height(); I get 596 x 456.

    Doesn't take a rocket scientist to figure out that there is a 4 pixel difference there (is that always going to be the case???), however I'm failing to understand why it's there in the first place? Just accept it, account for it and move on?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Size Difference

    If the widget on a layout, then the layout will decide the size (unless fixed size widget).

    The size from designer to run time should not change.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Size Difference

    I have made the widget as big as the window will go and it remains proportional to the size of the window when I resize the window, however the size of the window in designer is a different size under 'geometry' than when i 'fetch' the size of this widget form within my program and I'm not sure where the difference comes from?

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Size Difference

    It is important note that geometry() will return a proper position and size only after the widget is displayed (i.e. show() is called and painted)

    I have made the widget as big as the window will go and it remains proportional to the size of the window when I resize the window
    Does that mean you have one widget on a top level widget?
    When say resize and propostional, it kind of implies that you are using some layout manager. As I said earlier the layout manager will resize (change the widget size) to fit it into the parent window/widget, and will also add the margins. These margins will cause the widget to shrink.

    If you are using layouts then use setMargins(0);
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Jun 2011
    Posts
    203
    Thanks
    7
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Size Difference

    I tried to get the geomtery of the widget inside the OpenGL PainGL function, so it's certainly after show(). I did not create the widget via code from a clean slate, I used 'Design Editor'. As you can somewhat see in the attachment, the widget is centre adjusted for height and width, so it will always have the border as seen there - which is fine, however why there is a discrepancy between its geometry in design and when I run the app (before I attempt to re-size the window obviously), is quite surprising.

    Widget.jpg

  6. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Size Difference

    I cannot see the attachment clearly, but it seems your problem is with layout margin. Did you try setting setMargin(0)?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. What's the difference?
    By Atomic_Sheep in forum Newbie
    Replies: 3
    Last Post: 6th September 2012, 12:36
  2. Replies: 0
    Last Post: 14th February 2012, 16:43
  3. font size difference in embedded QT
    By plambert in forum Qt for Embedded and Mobile
    Replies: 6
    Last Post: 14th February 2012, 10:40
  4. Replies: 0
    Last Post: 26th October 2010, 18:59
  5. Replies: 2
    Last Post: 23rd March 2009, 18:26

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.