PDA

View Full Version : Want a preview(image) besides the cursor when it clicks on a QListWidgetItem in list



Charvi
14th March 2012, 12:13
Hi everybody,

I have a QListWidget with four QListWidgetItems.
I have implements a drag and drop on the list items from the list view
to another graphics view. Now I want that whenever I click on one of the
items in the list then along with the hand cursor a small preview like
image should appear. The image source should be resources folder
preferably. The feature is already there in the QtDesigner. Whenever we
click on any widget name in the widget list on the left hand side, with
the intension of dragging it to the form then a small preview of the
widget appears on the right of the hand like cursor. I want the same.
Please help.

Thanks in advance.
Charvi Mehta.

Spitfire
16th March 2012, 14:38
Use QListWidget::itemClicked() or similar signal to know when the item was activated.
From that signal you get activated QListWidgetItem from which you can get ie path to your resources.
Having that you can use QLabel to display the image and position it using QCursor::pos().

If you want to move the preview as the mouse moves, you'll need to implement mouseMoveEvent() and set mouse tracking to on.