Important: Please read the Qt Code of Conduct -

How to fix the treeview on left hand side of main window.

  • Hi All

    I have created a mainwindow.
    In this main window i want to fit treeview so i created my own custom treeview.
    Now by using QDockWidget i fitted that treeview on left side of mainwindow.

    QDockWidget *dock = new QDockWidget(tr(""), this);
    view = new QTreeView(dock);
    addDockWidget(Qt::LeftDockWidgetArea, dock);@

    Above code is working fine but when i maximise my mainwindow treeview is covering the complete central space of mainwindow.

    I want treeview to remain same on left hand side.
    How to fix this?

  • bq. Each widget returns a QSizePolicy that describes the horizontal and vertical resizing policy it prefers when being laid out. You can change this for a specific widget by changing its "QWidget::sizePolicy": property. QSizePolicy contains two independent "QSizePolicy::Policy": values and two stretch factors; one describes the widgets's horizontal size policy, and the other describes its vertical size policy. It also contains a flag to indicate whether the height and width of its preferred size are related.


Log in to reply