Results 1 to 5 of 5

Thread: QTableWidget resize to screen

  1. #1
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableWidget resize to screen

    I use Qt Nokia SDK, i test my application on Maemo simulator.
    I created a QTableWidget with 2 rows and 7 columns. I have a layout.
    Earlier i tried a QCalendarWidget. When i add QCalendarWidget to my layout - no problem - it resizes to the layout. But when i add my QTableWidget to the layout it doesn't resizes. I tried several things, but all of them are fixed, and if I turn the phone - the size of the widget doesn't change, but i need it to take the whole screen like QCalendarWidget does. Can someone help me with this one?

    I use QWidget as my main thing were I have a layout
    Qt Code:
    1. QVBoxLayout *layout;
    To copy to clipboard, switch view to plain text mode 

  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: QTableWidget resize to screen

    You need to add the widget to the layout properly and set size policies properly.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget resize to screen

    Hm... I think I did a mistake there - the QTableWidget is properly aligned, But the columns are not. Can i somehow resize the columns, for them to fit the Layout?

    Picture:
    Nokia Week View.jpg

    And if i turn the phone vertically, then i cannot see all of the columns at once...

  4. #4
    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: QTableWidget resize to screen

    Yes, you can resize columns using the API of QHeaderView or QTableView.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Feb 2011
    Location
    Latvia
    Posts
    139
    Thanks
    24
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableWidget resize to screen

    Hm... But is there a function to resize columns not to fixed size, not to contents, but to layout in which the QTableWidget is?


    Added after 12 minutes:


    Well i tried
    table->horizontalHeader()->resizeSections(QHeaderView::Stretch);

    I thought it should do the job but instead i got this:
    Nokia Week View 2.jpg

    Any ideas?


    Added after 8 minutes:


    Well, I think i solved this one.
    I should've used
    Qt Code:
    1. table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    To copy to clipboard, switch view to plain text mode 
    Last edited by Archa4; 31st March 2011 at 11:37.

Similar Threads

  1. Detect screen rotation or resize
    By leoalvesmachado in forum Newbie
    Replies: 2
    Last Post: 9th April 2010, 01:20
  2. How to get screen resize event?
    By kamlesh.sangani in forum Qt Programming
    Replies: 8
    Last Post: 10th March 2010, 08:46
  3. Replies: 2
    Last Post: 25th February 2010, 10:28
  4. How to resize the openfiledialog to 320x240 Screen?
    By augusbas in forum Qt Programming
    Replies: 4
    Last Post: 7th July 2009, 09:13
  5. QTableWidget resize
    By MarkoSan in forum Qt Programming
    Replies: 8
    Last Post: 16th January 2008, 14:18

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.