Important: Please read the Qt Code of Conduct -

[Solved] QPushButton change text

  • 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
    When I compile the code it says: Invalid use of non-static data member 'pushButton'
    How do I get around this problem?

  • Hello

    I think you shouldn't access your pushButton like that, it's not a static member. Try with




    Whether your Ui_mainWindow is created on heap or stack. Does this work?


    PS: next time, type your code between "@", that will make things neat and clear.

  • Thanks, but unfortunately this doen't work either. The compiler now gives the error: "expected unqualified-id" for both options.

  • Hmmm

    Could you provide some more code if possible please?


  • Do this:

  • Thanks, that worked. I see what I was doing wrong now.

Log in to reply