how to make make qsplitter unmovable by user and add possibility to enable/disable this function? Thankyou.
Blocking the QSplitter
handler can be done using the QSplitterHandler as @G.M. suggested in the comment.
Here is an example code (assuming you'r using QMainWindow
)
#include <QCheckBox>
#include <QSplitter>
#include <QLabel>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QSplitter * poSplitter = new QSplitter(this);
QLabel * poLbl = new QLabel("Some place holer",this);
QCheckBox * poToggleSplitter = new QCheckBox("Block splitter", this);
poSplitter->addWidget(poLbl);
poSplitter->addWidget(poToggleSplitter);
connect(poToggleSplitter, &QCheckBox::clicked,
[poSplitter](bool bChecked)
{
// Block splitter movement
poSplitter->handle(1)->setEnabled(!bChecked);
});
this->setCentralWidget(poSplitter);
}