Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. invalid use of member (did you forget '&')
Forum Updated to NodeBB v4.3 + New Features

invalid use of member (did you forget '&')

Scheduled Pinned Locked Moved Unsolved General and Desktop
qpushbutton
5 Posts 3 Posters 2.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lorence
    wrote on last edited by Lorence
    #1

    QPushButton inherits QString text from QAbstractButton.
    MyClass inherits QPushButton, some function of MyClass uses QString text directly.
    heres my code:
    void MyCLass::mouseReleaseEvent(QMouseEvent *e)
    {
    if ( e->button() == Qt::LeftButton )
    {
    emit clickedToPause(QMediaPlayer::State::PausedState);
    if ( text == "Pause" ) text = "Resume";
    else text = "Pause";
    }
    }

    error: invalid use of member (did you forget the '&' ?)
    if ( text == "Pause" ) text = "Resume";

    i have no idea in that error

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      what about setText("Resume"); ?

      L 1 Reply Last reply
      0
      • mrjjM mrjj

        what about setText("Resume"); ?

        L Offline
        L Offline
        Lorence
        wrote on last edited by Lorence
        #3

        @mrjj thats what i did, but i decided to go directly to member text for speed.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          There's no "member" text, text is a property which has a getter named text() so what you are currently doing is trying assign a string to a method.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • L Offline
            L Offline
            Lorence
            wrote on last edited by Lorence
            #5

            i see thanks

            thanks all

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved