QSplitter size [SOLVED]
-
I want to resize the
QSplitter
to a default position and set the minimum width/height of each one.The code:
auto hsplitter = new QSplitter(Qt::Horizontal); auto vsplitter = new QSplitter(Qt::Vertical); auto listview = new QListView; auto treeview = new QTreeView; auto textedit = new QTextEdit; hsplitter->addWidget(listview); hsplitter->addWidget(vsplitter); vsplitter->addWidget(treeview); vsplitter->addWidget(textedit); setCentralWidget(hsplitter);
-
Is there anyone that can help me with that?
-
Hi,
you can try with QSplitter::setStretchFactor or QSplitter::setSizes to resize the splitter. -
@stephane78 I tried both and doesn't work.
-
Hi,
I have put for example, these 4 lines just before setCentralWidgethsplitter->setStretchFactor(1,3); vsplitter->setStretchFactor(0,2); vsplitter->setStretchFactor(1,1); ``` and it works.
-
HI,
the first line of code was :
hsplitter->setStretchFactor(0,1); ....
-
Hi,
for the minimum width/height try QWidget::setMinimumSize. -
@stephane78 Thank you very much, you rock. ♥
-
thank you ,
you're welcome,you can find the documentation of Qt classes on doc.qt.io if you haven't installed on your hard drive the html documentation of Qt.
-
@stephane78 I tried to read there but I couldn't find an explanation of the usage.
1/10