Results 1 to 1 of 1

Thread: QTableWidget::setCellWidget and size

  1. #1
    Join Date
    Jul 2012
    Posts
    244
    Thanks
    27
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableWidget::setCellWidget and size

    I have a separate widget consisting of a QTextEdit and a few buttons. The QTextEdit has a preferred size and grows as the widget is resized. All of this works fine.

    however, when i want to set this widget into the cell of a QTableWidget, using tw->setCellWidget(a,b,mywid), then my widget is much bigger than its preferred size.


    Qt Code:
    1. for(...rows...)
    2. for(...cells...)
    3. tablewidget->setCellWidget(row, cell, new mywid());
    4.  
    5. tablewid->resizeColumnsToContents();
    6. tablewid->resizeRowsToContents();
    To copy to clipboard, switch view to plain text mode 


    I can then proceed to manually resize the column width, which shrinks my widget accordingly.
    The question is, why doesnt setCellWidget() respect my wished size?


    mywidget->show()

    pops up the widget, sized correctly.

    edit:
    no, i was wrong: sizeHint() returns an incorrect size! Why is that? Why is it show()n sized correctly?
    Last edited by tuli; 7th October 2013 at 11:07.

Similar Threads

  1. setCellWidget - strange behavior
    By Archa4 in forum Newbie
    Replies: 5
    Last Post: 28th April 2011, 08:26
  2. QTableWidget + setCellWidget facing problem.
    By danish.ahmed in forum Newbie
    Replies: 14
    Last Post: 19th October 2010, 11:33
  3. Replies: 7
    Last Post: 18th September 2009, 10:59
  4. setCellWidget for every row
    By gemidjy in forum Qt Programming
    Replies: 7
    Last Post: 24th March 2008, 22:03
  5. Replies: 10
    Last Post: 9th July 2007, 22:02

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.