Results 1 to 3 of 3

Thread: QMainWindow -> centralWidget size

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Location
    Craiova, Romania
    Posts
    46
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QMainWindow -> centralWidget size

    Hello! I am trying to make a scaled drawing on a main form. For this, I took the centralWidget width() and height() and compute the dimensions of the drawing. But I have a problem:

    Say the initial size of central widget is 400x300. After I show the QMainWindow, the size is the same. But if I manually resize the QMainWindow with just 1 pixel, or just modify width, the height of the central widget automatically decreases by 21 (so it is now 400x279).

    What am I doing wrong?

    Edited to add more details: I am using a designer ui file, a QMainWindow descendant, with a menu implemented in the designer. When I get the geometry of the central widget, x is 0 and y is 2 (so it may be wrong the y? Because the menu bar has a height of about 20). After I manually resize the main form, y becomes 23 (and x stays 0). So, the geometry of the central widget before the manual resize seems wrong.

    Also, if I write in code: main form resize(30,30) and resize(old x,old y), the geometry of the central widget is correct now (x=0, y=23).

    Edited to add: of course I reimplemented the resizeEvent to update my resizable drawing (I draw a few lines, taking into account the available size of central widget).

    Edited to add: I found this link: http://www.qtcentre.org/forum/f-qt-p...post86938.html
    The person says it is a Qt bug, because the menu bar is reporting height = 2 incorrectly, but how can I find when it will be solved?

    Edited to add: the bug is on: http://qt.nokia.com/developer/task-t...ntry&id=237451
    Could you suggest a workaround?
    Last edited by lalesculiviu; 24th October 2009 at 14:47. Reason: updated contents

Similar Threads

  1. Replies: 2
    Last Post: 23rd March 2009, 17:26
  2. Maximumsize by layout QMainWindow
    By captiva in forum Qt Programming
    Replies: 7
    Last Post: 24th February 2009, 19:41
  3. Shrink QMainWindow to Minimum Size
    By kloffy in forum Qt Programming
    Replies: 4
    Last Post: 17th February 2008, 17:54
  4. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 17:57
  5. QMainWindow: problem changing centralWidget
    By Caius Aérobus in forum Qt Programming
    Replies: 6
    Last Post: 4th October 2007, 13:00

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.