I have a horizontal layout inside which i have added a group box. The group box is split using a QSplitter
and contain a QListWidget
and a QTextBrowser
. I want to add two push buttons at the bottom right corner of the window to navigate inside the QTextBrowser
. I'm adding two buttons inside the layout but unable to add them at the bottom right corner. Here is my code:
_groupBox = new QGroupBox();
_groupBox->setTitle("Config Help System");
_verticalLayout = new QVBoxLayout(_groupBox);
this->setLayout(_verticalLayout);
_splitter = new QSplitter(_groupBox);
_splitter->setOrientation(Qt::Horizontal);
_list = new QListWidget(_splitter);
QListWidgetItem *item1 = new QListWidgetItem;
item1->setText("About Config Tool");
_list->insertItem(0, item1);
QListWidgetItem *item2 = new QListWidgetItem;
item2->setText("Configuration Help");
_list->insertItem(1, item2);
_list->setSelectionMode(QAbstractItemView::SingleSelection);
_splitter->addWidget(_list);
_helpBrowser = new QTextBrowser(_splitter);
_homeButton = new QPushButton(tr("&Home"), this);
_backButton = new QPushButton(tr("&Back"), this);
_closeButton = new QPushButton(tr("&Close"), this);
QHBoxLayout *buttonLayout = new QHBoxLayout(this);
buttonLayout->addWidget(_homeButton);
buttonLayout->addWidget(_backButton);
buttonLayout->addStretch(1);
buttonLayout->addWidget(_closeButton)
_splitter->addWidget(_helpBrowser);
_splitter->setStretchFactor(1,1);
_verticalLayout->addWidget(_splitter);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
this->resize(1000,600);
I have tried the stretch factor to adjust the buttons to appear at the bottom right corner to the splitter. Can anyone please help me with it?