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();
QVBoxLayout *_verticalLayout = new QVBoxLayout(_groupBox);
QSplitter *_splitter = new QSplitter(_groupBox);

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);

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);




www->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

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?

At line 24 remove the this because that makes the current class (window/widget) the parent but line 36 tries to make the _verticalLayout the parent too and causes the warning since the parent is already set.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.