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:
QWidget *www = new QWidget;
QGroupBox* _groupBox = new QGroupBox();
_groupBox->setTitle("Info");
QVBoxLayout *_verticalLayout = new QVBoxLayout(_groupBox);
www->setLayout(_verticalLayout);
QSplitter *_splitter = new QSplitter(_groupBox);
_splitter->setOrientation(Qt::Horizontal);
QListWidget *_list = new QListWidget(_splitter);
QListWidgetItem *item1 = new QListWidgetItem;
item1->setText("List1 Info");
_list->insertItem(0, item1);
QListWidgetItem *item2 = new QListWidgetItem;
item2->setText("List2 Info");
_list->insertItem(1, item2);
_list->setSelectionMode(QAbstractItemView::SingleSelection);
_splitter->addWidget(_list);
QTextBrowser *_helpBrowser = new QTextBrowser(_splitter);
QPushButton* _homeButton = new QPushButton("home");
QPushButton* _backButton = new QPushButton("back");
QPushButton *_closeButton = new QPushButton("close");
QHBoxLayout *buttonLayout = new QHBoxLayout(this);
buttonLayout->addWidget(_closeButton);
buttonLayout->addStretch(1);
buttonLayout->addWidget(_homeButton);
buttonLayout->addWidget(_backButton);
_splitter->addWidget(_helpBrowser);
_splitter->setStretchFactor(1,1);
_verticalLayout->addWidget(_splitter);
_verticalLayout->addLayout(buttonLayout);//new
www->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
www->resize(1000,600);
www->show();
Adding the HBoxLayout to the VBoxLayout doesnt work well for me. I get a warning that says QLayout::AddChildLayout: layout already has a parent' but displays in correct format. How do i get all the elements correctly positioned without getting the QT Warning?