access the widget dynamically
hi
im displaying many buttons dynamically in the application based on the count from the
database.each button has name.when a query is processed a button name is received.
so i need to highlight the corresponding button in the front end application..
how to do ??either a cast from string to qpushbutton possible??
or finding the buttons in the front end with the given name??
can any one help??
thanks in advance!!!:crying::confused:
Re: access the widget dynamically
there are several ways... but if i understood correctly.. on creation of buttons you can use a QHash
QHash<QString, QPushButton*> hash;
QString name = getNameFromSomeWhere();
QPushButton * btn = new QPushButton(name,this);
hash.insert(name,btn);
and so on
Re: access the widget dynamically
Or you can use QObject::findChild():
Code:
QPushButton *button
= parentWidget
->findChild<QPushButton
*>
("button1");
Re: access the widget dynamically
hi mrdeath
i ll try wat u said ,and then come back..
thanks a lot:):)
Re: access the widget dynamically
hi Lykurg
thanks a lot it worked well.
thanksss:D:D
qtcentre is great