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. Is there something like a "cursorForPosition" for QLineEdits?
Forum Updated to NodeBB v4.3 + New Features

Is there something like a "cursorForPosition" for QLineEdits?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 471 Views 1 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.
  • Z Offline
    Z Offline
    ZeHgS
    wrote on last edited by
    #1

    Hi everyone!

    Is there something like a "cursorForPosition" for QLineEdits?

    I want to implement a QLineEdit with functionality to detect where a mouse click occurred and respond accordingly. Do I need to use QTextEdits for this and make them look like QLineEdits?

    Thanks a lot!

    Pl45m4P 1 Reply Last reply
    0
    • Z ZeHgS

      Hi everyone!

      Is there something like a "cursorForPosition" for QLineEdits?

      I want to implement a QLineEdit with functionality to detect where a mouse click occurred and respond accordingly. Do I need to use QTextEdits for this and make them look like QLineEdits?

      Thanks a lot!

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @ZeHgS said in Is there something like a "cursorForPosition" for QLineEdits?:

      where a mouse click occurred and respond accordingly

      Use the mousePressEvent


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZeHgS
        wrote on last edited by ZeHgS
        #3

        Thanks a lot for replying! How do I detect which word was clicked on, though? Or place the text cursor at the position

        Pl45m4P eyllanescE 2 Replies Last reply
        0
        • Z ZeHgS

          Thanks a lot for replying! How do I detect which word was clicked on, though? Or place the text cursor at the position

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @ZeHgS

          You cant (out of the box). When you use mousePressEvents, you know where the click happened. The rest is on you what to do with this information.

          By default the cursor is going where you click, right?!
          LineEdit is a pretty simple input field. If you need further functionality to work with larger texts, you should have a look at QTextEdit or QPlainTextEdit.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          0
          • Z ZeHgS

            Thanks a lot for replying! How do I detect which word was clicked on, though? Or place the text cursor at the position

            eyllanescE Offline
            eyllanescE Offline
            eyllanesc
            wrote on last edited by
            #5

            @ZeHgS Use https://doc.qt.io/qt-5/qlineedit.html#cursorPositionAt

            If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

            Z 1 Reply Last reply
            4
            • eyllanescE eyllanesc

              @ZeHgS Use https://doc.qt.io/qt-5/qlineedit.html#cursorPositionAt

              Z Offline
              Z Offline
              ZeHgS
              wrote on last edited by
              #6

              @eyllanesc Thank you so much! I must be going blind. Thanks!

              Pl45m4P 1 Reply Last reply
              0
              • Z ZeHgS

                @eyllanesc Thank you so much! I must be going blind. Thanks!

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by
                #7

                @ZeHgS

                This is where the cursor is, but you asked for mouseClicks to detect words?
                The current cursor position is easy to determine like @eyllanesc wrote above.


                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                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