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 set the width of one column in treeview to be fixed and the other colume to be auto fit while window resized?
Forum Updated to NodeBB v4.3 + New Features

How to set the width of one column in treeview to be fixed and the other colume to be auto fit while window resized?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 11.5k Views 1 Watching
  • 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.
  • R Offline
    R Offline
    remember2015
    wrote on last edited by
    #1

    One problem in coding with treeview:
    @public class ReportGrid extends QTreeWidget {
    public ReportGrid (QWidget parent) {
    super(parent);
    this.setRootIsDecorated(false);
    this.setAlternatingRowColors(true);
    ArrayList<String> labels = new ArrayList<String>();
    labels.add("Description");
    labels.add("Requird");
    this.setHeaderLabels(labels);
    header().setResizeMode(QHeaderView.ResizeMode.Interactive);
    //this.setModel(model);
    this.setColumnWidth(0, 200);
    this.setColumnWidth(1, 20);
    }
    }@
    I want set the "Description" column 200px min width and "Required" column to be 20px width fixed(it contains an icon).
    But while window resizing the column “Requird” expands.
    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mohsen
      wrote on last edited by
      #2

      use header().setStretchLastSection(true);
      and remove header().setResizeMode(QHeaderView.ResizeMode.Interactive);

      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