Results 1 to 2 of 2

Thread: width()

  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default width()

    Hi, it happened a strange thing: I need to retrieve myWidget1 width and to uncover this I put code below inside mainForm constructor and MyWidget:aintGL()
    Qt Code:
    1. cout << width() << endl; //in paintGL() print 101
    2. cout << myWidget1->width() << endl; //in costructor of MainForm print 466 (truth)
    To copy to clipboard, switch view to plain text mode 
    I must obtain with from MainForm but I retieve 101 and it is wrong; why This? Thanks..
    Regards

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

    Default Re: width()

    You shouldn't try to fetch widget size in the constructor as its size is not set then yet. It is being set when show() is executed.

Similar Threads

  1. How to set QTableView width to width of horizontal header?
    By martinb0820 in forum Qt Programming
    Replies: 0
    Last Post: 2nd December 2008, 20:51
  2. Replies: 4
    Last Post: 15th October 2008, 13:24
  3. Scaling of pen width in QGraphicsView
    By spuds in forum Qt Programming
    Replies: 3
    Last Post: 30th May 2008, 01:47
  4. QTableWidget column width and resizing
    By shooogun in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2008, 22:31
  5. How to obtain the width of a QTableWidget?
    By Giel Peters in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2006, 22:34

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.