onClicked overriding onDoubleClicked
-
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
-
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
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.
-
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.
@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 -
@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 -
@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 onDoubleClickedTo 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.