[Solved] QPushButton change text
-
wrote on 26 Feb 2013, 20:57 last edited by
I am trying to make it so that when the pushButton is clicked the text on it changes. At the moment my programming in the slot is
@Ui_MainWindow::pushButton->setText("helloworld");@
When I compile the code it says: Invalid use of non-static data member 'pushButton'
How do I get around this problem? -
wrote on 26 Feb 2013, 21:42 last edited by
Hello
I think you shouldn't access your pushButton like that, it's not a static member. Try with
@Ui_MainWindow->pushButton->setText("clicked")@
Or
@Ui_MainWindow.pushButton->setText("clicked")@
Whether your Ui_mainWindow is created on heap or stack. Does this work?
Regards.
PS: next time, type your code between "@", that will make things neat and clear.
-
wrote on 26 Feb 2013, 22:10 last edited by
Thanks, but unfortunately this doen't work either. The compiler now gives the error: "expected unqualified-id" for both options.
-
wrote on 26 Feb 2013, 22:26 last edited by
Hmmm
Could you provide some more code if possible please?
Thanks!
-
wrote on 27 Feb 2013, 03:58 last edited by
Do this:
@ui->pushButton->setText("clicked")@ -
wrote on 27 Feb 2013, 08:07 last edited by
Thanks, that worked. I see what I was doing wrong now.