QT Get the list all button
up vote
-5
down vote
favorite
QObjectList list =children() ;
qDebug() << list.length() << endl;
QPushButton *b;
foreach (QObject *obj, list)
{
b = qobject_cast<QPushButton*>(obj);
if(b)
{
PushButtonStr.append( b->text());
qDebug() << b->text() << endl;
}
}
In Widget::Widget can get the list all button,but In my class can't get the button?
c++ qt
|
show 3 more comments
up vote
-5
down vote
favorite
QObjectList list =children() ;
qDebug() << list.length() << endl;
QPushButton *b;
foreach (QObject *obj, list)
{
b = qobject_cast<QPushButton*>(obj);
if(b)
{
PushButtonStr.append( b->text());
qDebug() << b->text() << endl;
}
}
In Widget::Widget can get the list all button,but In my class can't get the button?
c++ qt
3
You question is unclear, please check how to ask a good question.
– Shayn
Nov 11 at 11:22
QT get the list all Qpushbutton?
– user10635895
Nov 11 at 11:28
Hi there, welcome to SO. As much as we would like to help, it is difficult to understand what your question is trying to ask. You've provided code... but what does it do and what is its connection to the problem? What isWidget::Widget
? It doesn't look like a QWidget... What doeslist all button
mean? What isyour class
? Please don't assume we know everything and please make an attempt to clarify your question...
– TrebuchetMS
Nov 11 at 11:35
sorry,my English is very poor , I want to get all the QpushButton controls on the UI, "void PLC::SearchControl()" This is a PLC Class I wrote, in this class qDebug() << list.length() << endl; The result is 0, but the UI There are 5 buttons on it
– user10635895
Nov 11 at 12:00
Chinese:我想用我自己写的一个PLC类,来遍历UI界面上的所有按钮控件,代码上面已经列出,在PLC类里面直接children(),不能得到UI上的按钮控件,所以会返回0,放在Widget的构造函数里面是能正常遍历所有按钮控件的。问题:我在自己的类中如何去获取UI界面上的按钮控件
– user10635895
Nov 11 at 12:06
|
show 3 more comments
up vote
-5
down vote
favorite
up vote
-5
down vote
favorite
QObjectList list =children() ;
qDebug() << list.length() << endl;
QPushButton *b;
foreach (QObject *obj, list)
{
b = qobject_cast<QPushButton*>(obj);
if(b)
{
PushButtonStr.append( b->text());
qDebug() << b->text() << endl;
}
}
In Widget::Widget can get the list all button,but In my class can't get the button?
c++ qt
QObjectList list =children() ;
qDebug() << list.length() << endl;
QPushButton *b;
foreach (QObject *obj, list)
{
b = qobject_cast<QPushButton*>(obj);
if(b)
{
PushButtonStr.append( b->text());
qDebug() << b->text() << endl;
}
}
In Widget::Widget can get the list all button,but In my class can't get the button?
c++ qt
c++ qt
edited Nov 11 at 11:23
Mat
163k27306338
163k27306338
asked Nov 11 at 11:19
user10635895
1
1
3
You question is unclear, please check how to ask a good question.
– Shayn
Nov 11 at 11:22
QT get the list all Qpushbutton?
– user10635895
Nov 11 at 11:28
Hi there, welcome to SO. As much as we would like to help, it is difficult to understand what your question is trying to ask. You've provided code... but what does it do and what is its connection to the problem? What isWidget::Widget
? It doesn't look like a QWidget... What doeslist all button
mean? What isyour class
? Please don't assume we know everything and please make an attempt to clarify your question...
– TrebuchetMS
Nov 11 at 11:35
sorry,my English is very poor , I want to get all the QpushButton controls on the UI, "void PLC::SearchControl()" This is a PLC Class I wrote, in this class qDebug() << list.length() << endl; The result is 0, but the UI There are 5 buttons on it
– user10635895
Nov 11 at 12:00
Chinese:我想用我自己写的一个PLC类,来遍历UI界面上的所有按钮控件,代码上面已经列出,在PLC类里面直接children(),不能得到UI上的按钮控件,所以会返回0,放在Widget的构造函数里面是能正常遍历所有按钮控件的。问题:我在自己的类中如何去获取UI界面上的按钮控件
– user10635895
Nov 11 at 12:06
|
show 3 more comments
3
You question is unclear, please check how to ask a good question.
– Shayn
Nov 11 at 11:22
QT get the list all Qpushbutton?
– user10635895
Nov 11 at 11:28
Hi there, welcome to SO. As much as we would like to help, it is difficult to understand what your question is trying to ask. You've provided code... but what does it do and what is its connection to the problem? What isWidget::Widget
? It doesn't look like a QWidget... What doeslist all button
mean? What isyour class
? Please don't assume we know everything and please make an attempt to clarify your question...
– TrebuchetMS
Nov 11 at 11:35
sorry,my English is very poor , I want to get all the QpushButton controls on the UI, "void PLC::SearchControl()" This is a PLC Class I wrote, in this class qDebug() << list.length() << endl; The result is 0, but the UI There are 5 buttons on it
– user10635895
Nov 11 at 12:00
Chinese:我想用我自己写的一个PLC类,来遍历UI界面上的所有按钮控件,代码上面已经列出,在PLC类里面直接children(),不能得到UI上的按钮控件,所以会返回0,放在Widget的构造函数里面是能正常遍历所有按钮控件的。问题:我在自己的类中如何去获取UI界面上的按钮控件
– user10635895
Nov 11 at 12:06
3
3
You question is unclear, please check how to ask a good question.
– Shayn
Nov 11 at 11:22
You question is unclear, please check how to ask a good question.
– Shayn
Nov 11 at 11:22
QT get the list all Qpushbutton?
– user10635895
Nov 11 at 11:28
QT get the list all Qpushbutton?
– user10635895
Nov 11 at 11:28
Hi there, welcome to SO. As much as we would like to help, it is difficult to understand what your question is trying to ask. You've provided code... but what does it do and what is its connection to the problem? What is
Widget::Widget
? It doesn't look like a QWidget... What does list all button
mean? What is your class
? Please don't assume we know everything and please make an attempt to clarify your question...– TrebuchetMS
Nov 11 at 11:35
Hi there, welcome to SO. As much as we would like to help, it is difficult to understand what your question is trying to ask. You've provided code... but what does it do and what is its connection to the problem? What is
Widget::Widget
? It doesn't look like a QWidget... What does list all button
mean? What is your class
? Please don't assume we know everything and please make an attempt to clarify your question...– TrebuchetMS
Nov 11 at 11:35
sorry,my English is very poor , I want to get all the QpushButton controls on the UI, "void PLC::SearchControl()" This is a PLC Class I wrote, in this class qDebug() << list.length() << endl; The result is 0, but the UI There are 5 buttons on it
– user10635895
Nov 11 at 12:00
sorry,my English is very poor , I want to get all the QpushButton controls on the UI, "void PLC::SearchControl()" This is a PLC Class I wrote, in this class qDebug() << list.length() << endl; The result is 0, but the UI There are 5 buttons on it
– user10635895
Nov 11 at 12:00
Chinese:我想用我自己写的一个PLC类,来遍历UI界面上的所有按钮控件,代码上面已经列出,在PLC类里面直接children(),不能得到UI上的按钮控件,所以会返回0,放在Widget的构造函数里面是能正常遍历所有按钮控件的。问题:我在自己的类中如何去获取UI界面上的按钮控件
– user10635895
Nov 11 at 12:06
Chinese:我想用我自己写的一个PLC类,来遍历UI界面上的所有按钮控件,代码上面已经列出,在PLC类里面直接children(),不能得到UI上的按钮控件,所以会返回0,放在Widget的构造函数里面是能正常遍历所有按钮控件的。问题:我在自己的类中如何去获取UI界面上的按钮控件
– user10635895
Nov 11 at 12:06
|
show 3 more comments
1 Answer
1
active
oldest
votes
up vote
0
down vote
try to use
QList<QPushButton*> PbList = findChildren<QPushButton*>();
if you are inside a class derived from QObject, like i.e. QWidget
Qt doc
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
try to use
QList<QPushButton*> PbList = findChildren<QPushButton*>();
if you are inside a class derived from QObject, like i.e. QWidget
Qt doc
add a comment |
up vote
0
down vote
try to use
QList<QPushButton*> PbList = findChildren<QPushButton*>();
if you are inside a class derived from QObject, like i.e. QWidget
Qt doc
add a comment |
up vote
0
down vote
up vote
0
down vote
try to use
QList<QPushButton*> PbList = findChildren<QPushButton*>();
if you are inside a class derived from QObject, like i.e. QWidget
Qt doc
try to use
QList<QPushButton*> PbList = findChildren<QPushButton*>();
if you are inside a class derived from QObject, like i.e. QWidget
Qt doc
edited Nov 13 at 19:22
answered Nov 13 at 19:01
claude joliat
347
347
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248197%2fqt-get-the-list-all-button%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
You question is unclear, please check how to ask a good question.
– Shayn
Nov 11 at 11:22
QT get the list all Qpushbutton?
– user10635895
Nov 11 at 11:28
Hi there, welcome to SO. As much as we would like to help, it is difficult to understand what your question is trying to ask. You've provided code... but what does it do and what is its connection to the problem? What is
Widget::Widget
? It doesn't look like a QWidget... What doeslist all button
mean? What isyour class
? Please don't assume we know everything and please make an attempt to clarify your question...– TrebuchetMS
Nov 11 at 11:35
sorry,my English is very poor , I want to get all the QpushButton controls on the UI, "void PLC::SearchControl()" This is a PLC Class I wrote, in this class qDebug() << list.length() << endl; The result is 0, but the UI There are 5 buttons on it
– user10635895
Nov 11 at 12:00
Chinese:我想用我自己写的一个PLC类,来遍历UI界面上的所有按钮控件,代码上面已经列出,在PLC类里面直接children(),不能得到UI上的按钮控件,所以会返回0,放在Widget的构造函数里面是能正常遍历所有按钮控件的。问题:我在自己的类中如何去获取UI界面上的按钮控件
– user10635895
Nov 11 at 12:06