Is it possible to know the adress of all widgets in a QSplitter ?
-
All is in the title.
An example :
QWidget widget; QVBoxLayout *layout = new QVBoxLayout; QWidget *first = createQWidget(); QWidget *second = createQWidget(); QSplitter *split = new QSplitter; split->addWidget(first); split->addWidget(second); layout->addWidget(split); widget.setLayout(layout);
And now in another function, I have simply split and I want to obtain first and second. Is it possible?
-
split->children()
should contain your widgets. You can give themobjectName
to make searching even easier. -
@bozo6919 said in Is it possible to know the adress of all widgets in a QSplitter ?:
@sierdzio I can do simply like this :
QObjectList widgetList = split->children(); QWidget *saveWidget = (QWidget *)widgetList[0]; QWidget *delWidget = (QWidget *)widgetList[1];
Or something wrong ?
It is OK. I'd only recommend to check
widgetList
size before trying to access the list elements. -
@bozo6919 said in Is it possible to know the adress of all widgets in a QSplitter ?:
If I know just the QWidget Second, I can search the split with second->parent() ?
Yes. If QSplitter assigns itself as parent of the widgets it splits, it should work.
-
@bozo6919 said in Is it possible to know the adress of all widgets in a QSplitter ?:
Okei, thanks :)
How put the topic in solved ? ^^'
Click the 3 dots to the right of the solving post, and there click on "mark as solved".
And I have another question, I say it here or I create a new topic?
Better open another topic.