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. onClicked overriding onDoubleClicked
Qt 6.11 is out! See what's new in the release blog

onClicked overriding onDoubleClicked

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 626 Views 3 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.
  • Seb TurS Offline
    Seb TurS Offline
    Seb Tur
    wrote on last edited by
    #1

    Hi

    I have a QTableView where onClicked runs a QSqlQuery to check more details of row that was clicked.
    I also use onDoubleClicked for this QTableView to display all child elements of a row with another QSqlQuery.

    All works fine except for the case when user is using a VPN and slow connection.
    Then the doubleclick is not recorded at all.
    I observerd the first click of doubleClick is registgered as a regular onClicked and kicks in with its job that takes some second or two, so the second click of the doubleclick is not registared as part of the doubleclick it was supposed to be in.

    Any suggestions? I thought maybe moving whole onClick to a separate thread would be a cure but I would like to avoid that if there are other options

    Chris KawaC 1 Reply Last reply
    0
    • Seb TurS Seb Tur

      Hi

      I have a QTableView where onClicked runs a QSqlQuery to check more details of row that was clicked.
      I also use onDoubleClicked for this QTableView to display all child elements of a row with another QSqlQuery.

      All works fine except for the case when user is using a VPN and slow connection.
      Then the doubleclick is not recorded at all.
      I observerd the first click of doubleClick is registgered as a regular onClicked and kicks in with its job that takes some second or two, so the second click of the doubleclick is not registared as part of the doubleclick it was supposed to be in.

      Any suggestions? I thought maybe moving whole onClick to a separate thread would be a cure but I would like to avoid that if there are other options

      Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Do you mean you're blocking the UI thread until you get a network query response from the first click? You should pretty much never do that. There are UI responsiveness guidelines and you can never meet them with something as volatile as network timings. A whole bunch of stuff will break this way, not just mouse clicks.

      A rule of thumb is if you don't know how long something can take move it to another thread and code your UI thread as if that thing takes an hour i.e. there should be no blocking wait for it or, if you have to wait, show a progress bar/spinner/whatever and add a timeout. Keep UI responsive at all times e.g. you should be able to move your window or hover UI elements while you wait for some network response. UI event processing should never be blocked by waiting on network. There's always a cat that can chew on a router cable and your UI should handle that gracefully.

      Seb TurS 1 Reply Last reply
      4
      • Chris KawaC Chris Kawa

        Do you mean you're blocking the UI thread until you get a network query response from the first click? You should pretty much never do that. There are UI responsiveness guidelines and you can never meet them with something as volatile as network timings. A whole bunch of stuff will break this way, not just mouse clicks.

        A rule of thumb is if you don't know how long something can take move it to another thread and code your UI thread as if that thing takes an hour i.e. there should be no blocking wait for it or, if you have to wait, show a progress bar/spinner/whatever and add a timeout. Keep UI responsive at all times e.g. you should be able to move your window or hover UI elements while you wait for some network response. UI event processing should never be blocked by waiting on network. There's always a cat that can chew on a router cable and your UI should handle that gracefully.

        Seb TurS Offline
        Seb TurS Offline
        Seb Tur
        wrote on last edited by
        #3

        @Chris-Kawa
        While I agree to general concept of separating GUI from real business logic actions I still think onClicked shouldn't be called in the first place.
        It should be onDoubleClicked

        JonBJ Pl45m4P 2 Replies Last reply
        0
        • Seb TurS Seb Tur

          @Chris-Kawa
          While I agree to general concept of separating GUI from real business logic actions I still think onClicked shouldn't be called in the first place.
          It should be onDoubleClicked

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Seb-Tur
          I don't think most systems work like that. For one thing that would mean that every time the user clicks the system would have to wait to see whether it's a double click, which introduces a delay on single clicks.

          1 Reply Last reply
          3
          • Seb TurS Seb Tur

            @Chris-Kawa
            While I agree to general concept of separating GUI from real business logic actions I still think onClicked shouldn't be called in the first place.
            It should be onDoubleClicked

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

            @Seb-Tur

            To take it even further than @JonB did:
            A single "click" is actually a mouse press, followed by a mouse release in the same context (widget).
            While some widgets are triggered on release, some are at mouse "down", which could not only result in a single, or later double click, but also in some drag'n'drop action.


            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
            2

            • Login

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