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. Help with QLineEdit's slots
Qt 6.11 is out! See what's new in the release blog

Help with QLineEdit's slots

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.6k 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.
  • S Offline
    S Offline
    smoyertech
    wrote on last edited by
    #1

    I have a list of callout objects that are created/displayed on an image. Each of these callout objects contain a QLineEdit object. Each QLineEdit object is connected to it's own signal/slot method. The user can move the mouse around and edit the text in any one of the callouts displayed. In the textEdited signal handler / slot method I want to know which of the callouts I am currently editing in, but all I know is the QString that is passed into it. Any recommendations on how I might be able to do this do this? (This is my first Qt application)

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

      hi and welcome
      Inside a slot you can use the sender() function
      to know which QWidget/QObject that gave/send you the textEdited signal. (or any signal)

      To get the actual QLineEdit, you need to cast it:

      QLineEdit * LineSender=qobject_cast<QLineEdit *>(sender());
      if (LineSender)
      LineSender->xxxx

      S 1 Reply Last reply
      3
      • S smoyertech

        I have a list of callout objects that are created/displayed on an image. Each of these callout objects contain a QLineEdit object. Each QLineEdit object is connected to it's own signal/slot method. The user can move the mouse around and edit the text in any one of the callouts displayed. In the textEdited signal handler / slot method I want to know which of the callouts I am currently editing in, but all I know is the QString that is passed into it. Any recommendations on how I might be able to do this do this? (This is my first Qt application)

        K Offline
        K Offline
        koahnig
        wrote on last edited by
        #3

        @smoyertech

        Hi and welcome to devnet

        Probably some code highlighting your issue would be helpful.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply
        2
        • mrjjM mrjj

          hi and welcome
          Inside a slot you can use the sender() function
          to know which QWidget/QObject that gave/send you the textEdited signal. (or any signal)

          To get the actual QLineEdit, you need to cast it:

          QLineEdit * LineSender=qobject_cast<QLineEdit *>(sender());
          if (LineSender)
          LineSender->xxxx

          S Offline
          S Offline
          smoyertech
          wrote on last edited by A Former User
          #4

          @mrjj Thanks that worked well ...

          QLineEdit * lineSender=qobject_cast<QLineEdit *>(sender());
          foreach(CalloutData *cod, m_calloutList) {
                  //qDebug() << lineSender << cod->labelLineEdit();
                  if (lineSender == cod->labelLineEdit()) {
                      m_currentlySelectedCallout = cod;
                      break;
                  }
           }
          
          mrjjM 1 Reply Last reply
          0
          • S smoyertech

            @mrjj Thanks that worked well ...

            QLineEdit * lineSender=qobject_cast<QLineEdit *>(sender());
            foreach(CalloutData *cod, m_calloutList) {
                    //qDebug() << lineSender << cod->labelLineEdit();
                    if (lineSender == cod->labelLineEdit()) {
                        m_currentlySelectedCallout = cod;
                        break;
                    }
             }
            
            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @smoyertech
            Super. Im not sure why you have to loop over m_calloutList to find it ? (again?)

            if lineSender != NULL it means it was a LineEdit sending the signal so
            i do wonder why lineSender is not just cod->labelLineEdit ?

            S 1 Reply Last reply
            1
            • mrjjM mrjj

              @smoyertech
              Super. Im not sure why you have to loop over m_calloutList to find it ? (again?)

              if lineSender != NULL it means it was a LineEdit sending the signal so
              i do wonder why lineSender is not just cod->labelLineEdit ?

              S Offline
              S Offline
              smoyertech
              wrote on last edited by
              #6

              @mrjj I'm just plugging away right now... The CalloutData objects contain other properties, such as color to indicate whether something has been entered, that need to be modified. That's what they want :)

              1 Reply Last reply
              1

              • Login

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