Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to autofit widget size and position to a cell in QTreeWidget?
Forum Updated to NodeBB v4.3 + New Features

How to autofit widget size and position to a cell in QTreeWidget?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    flammmable
    wrote on last edited by flammmable
    #1

    I pragrammaticaly create a QTreeWidget (myTree).
    Then I pragrammaticaly add some items (item1, item2).
    Then I add two QLabel widgets to two items (QTreeWidgetItem) by

    myTree->setItemWidget(item1, 0, myLabel1);
    myTree->setItemWidget(item2, 0, myLabel2);
    

    And then I try to resize the row of the item pragrammaticaly. If I use an

    item1->setSizeHint(0, QSize(myWidth, myHeight) );
    

    the row chaged. But the myLabel1 is not. If I use an

    item1->setSizeHint(0, QSize(myWidth, myHeight) );
    myLabel1->resize(myWidth, myHeight);
    

    everething is ok but the row of myLabel2 mis adjusting to label by position.
    Can I do something to auto-adjusting a widget (by size and position) to a cell of QTreeWidget?

    P.S. After any resizing of tree (resize by width or expand/collapse node) widgets updates correctly.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      flammmable
      wrote on last edited by
      #2

      myTree->resizeColumnToContent(0);

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved