c++ - How i can change number that displaying on QPushButton? -
i have qpushbutton, button has text on it, text number. in slot of object want change number displayed on button, when call
mybutton->settext(qstring("%1").arg(number)); or
qstring tmp; tmp.setnum(number); mybutton->settext(tmp); text on button dosen't changes. when call
mybutton->settext("some random text"); it works fine. how can change number displaying on button?
part of code:
sortwindow::sortwindow(qwidget *parrent) { ... mybutton = new qpushbutton; qstring tmp(qstring("%1").arg(number)); mybutton.settext(tmp); ... } and
void sortwindow::workonsignal(int index) { ... if (something) { ... qstring tmp; tmp.setnum(number); mybutton->settext(tmp); ... }
type of number must int. work properly.
#include <qapplication> #include <qpushbutton> int main(int argc,char **argv) { qapplication app(argc,argv); qpushbutton *pd = new qpushbutton; pd->settext(qstring("%1").arg(1234)); pd->show(); return app.exec(); }
Comments
Post a Comment