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. Getting event filter to detect which line edit is clicked
Qt 6.11 is out! See what's new in the release blog

Getting event filter to detect which line edit is clicked

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.1k 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.
  • T Offline
    T Offline
    tony67
    wrote on last edited by tony67
    #1

    Hi All,
    I have a form with a number of line edits, when the user right clicks on a line edit I want to set up an even filter that opens a file dialog to allow the line edit to be filled with a file name. I've worked out how to get event filters running with a left click, however how do I determine if its line edit 1,2,3 ect?
    Thanks

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

      hi
      you get the lineedit in
      eventFilter( QObject * object ...)

      So object is the line edit.
      you can then cast it to lineedit.
      QLineEdit *TheOne= qobject_cast<QLineEdit *>(object ) ;
      if (TheOne) {
      OpenDialog()
      TheOne->setText(xxx);
      }

      1 Reply Last reply
      2
      • T Offline
        T Offline
        tony67
        wrote on last edited by
        #3

        Thanks for the advise

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          As a side note: Opening a file browse dialog on a right click is not a very common behavior. Usually a small "..." button next to the edit is used for this sort of thing, so a user can discover it easily. It also makes connecting it to the right open function easier.

          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