Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to resize QSplitter automatically according to QWidget
NIXIN last edited by
I have tried something like below:
QWidget *wid = new QWidget;
QSplitter *hSplitter = new QSplitter(Qt::Horizontal, wid);
QTabWidget *tWid = new QTabWidget;
QTextBrowser *tBrowser = new QTextBrowser;
what I want is that QSplitter should automatically resize according to QWidget, when the window is minimized or maximized
but its not happening
QSplitter size is fixed, it is not resizing.
Please suggest how to achieve it.
VRonin last edited by
You have to insert the splitter in a layout
QWidget *wid = new QWidget; QSplitter *hSplitter = new QSplitter(Qt::Horizontal, wid); QHBoxLayout* widLay=new QHBoxLayout(wid); hSplitter->addWidget(hSplitter); // all the rest
Btw, make sure you are not leaking memory in
wid, give it a parent or handle the delete
NIXIN last edited by NIXIN
I tried what you suggested with a little change
QWidget *wid = new QWidget; QSplitter *hSplitter = new QSplitter(Qt::Horizontal, wid); QHBoxLayout* widLay=new QHBoxLayout(wid); widLay->addWidget(hSplitter);
This works fine when I run the code, and show the QWidget (here wid) from the menu.
But when I close it and again show the QWidget from the menu, widLay is not covering the entire widget, only some part in the top left corner, and rest widget is blank.
And I also observe something on command line:
setGeometry: UInable to set geometry 540x241+1366+22 on QWidgetWindow........
Please suggest how to solve this.
Out of curiosity, why use a QSplitter at all since you don't use it of any resizing operation ?