Selecting Item and Scrolling ListWidget Area Problem
I am newbie on QT.
I need to list some selectable items on the screen. I decided to do it with ListWidget. I defined the stylesheet as follows.
color: rgb(255, 255, 255);
background-color: rgb(0, 0, 127);
border-color: rgb(65, 65, 65);
background-color: rgb(0, 85, 255);
Everything Ok without a problem.
I press on an item and select it. Then I move the cursor to next item without releasing the button. Previous item unselected but next item selected and so on... I do not want to select next item. Only the first pressed item should be selected if cursor on it, not others.
Also if I move the cursor out of ListWidget area scrolling is working. I want to stop the scrolling because I am using up-down buttons to navigate pages. Scrolling is too slow on my device.
I solved scrolling problem with
Item selecting problem continue, please help...
For more readability use the "@""@" tag for your code.
As for you problem, have you tried this:
I have tried all of the modes, however it is not the solution or I could not.
Hi and welcome to devnet,
Have a look at setSelectionMode and ExtendedSelection
Thank you sGaist,
I tried ExtendedSelection, but I need select only one item. I want to highlight only first pressed item if cursor on it until I release mouse button.
In other words, If I press mouse button on an item, I don't want hover effect on other items.
What you are trying to do looks like the drag and drop functionality but without actually doing anything. It doesn't fit in any usual use case of that widget.
Do you have any suggestion to do such a functionalty?
I see it on IOS apps, if Kinetic Scrolling not used.
On Android apps it is different. If you press on an item, app highlight that item, However if you move the cursor (or your finger on touch screens) without relesing, that item can not be selected again.
You would probably need to customize the mouse event handling by subclassing QListWidget
Should I do this with code handling or a QListWidget method?
Have a look at the mouseXXXEvent methods
Thank you for your help...