A
A
arama922019-02-03 00:52:05
Qt
arama92, 2019-02-03 00:52:05

How to remove elements in Layout and Layout itself?

How to remove a group of widgets. There is a GridLayout. It contains various elements. On a button click inside the Layout, delete all the contents of the Layout and the Layout itself, how to do this? In Qt, this is somehow difficult to do.
5c561027d4ed7672050805.png
By clicking the "cancel" button, you must delete its GridLayout and all elements of this GridLayout.

void WorkPlace::Not_Add_Personal()
{
    QPushButton *myButton = qobject_cast<QPushButton *>(sender()); // Кнопка "отмена"
    //qDebug()<<myButton->parent()->objectName(); // показывает, что родитель ScrollArena, но ведь кнопка находится в gridLayout
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2019-02-04
@vt4a2h

Well layout is not necessarily the parent of the element that is added to it.
You can get any object visible in the designer via the ui. For example ui->tab_4...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question