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?
-
@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.
-
split->children()should contain your widgets. You can give themobjectNameto make searching even easier. -
split->children()should contain your widgets. You can give themobjectNameto make searching even easier. -
@sierdzio I can do simply like this :
QObjectList widgetList = split->children(); QWidget *saveWidget = (QWidget *)widgetList[0]; QWidget *delWidget = (QWidget *)widgetList[1];Or something wrong ?
@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
widgetListsize before trying to access the list elements. -
@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
widgetListsize before trying to access the list elements. -
@sierdzio Yes, thanks.
For search parents, it's the same?If I know just the QWidget Second, I can search the split with second->parent() ?
(I cannot test for the moment, I don't have my computer)@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 ?:
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.
-
Okei, thanks :)
How put the topic in solved ? ^^'
And I have another question, I say it here or I create a new topic?
@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.