federem
federem

Reputation: 299

Superimpose widgets in Qt designer

I have a Qt application and I would like to superimpose a button on a QTreeWidget using the layouts. In fact, when I click on an item, I want the button to set visible, and centered above the tree. The button have to stay at the foreground until I click. Is it possible ?

Upvotes: 2

Views: 1252

Answers (1)

Amartel
Amartel

Reputation: 4286

You could use QStackedLayout and change it's stacking mode to QStackedLayout::StackAll, when you need to show both widgets. Methods would be something like this:

void Widget::showButton()
{
    stackedLayout->setStackingMode(QStackedLayout::StackAll);
    stackedLayout->setCurrentWidget(widgetWithButton);
}

void Widget::hideButton()
{
    stackedLayout->setCurrentWidget(treeWidget);
    stackedLayout->setStackingMode(QStackedLayout::StackOne);
}

Upvotes: 2

Related Questions