PDA

View Full Version : itemDoubleClicked and itemClicked



miraks
7th August 2008, 22:18
Hi,

I created a QListWidget with items.
I would to catch an event when an item is clicked and an other event when double clicked.

I did:

connect(contextList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(setNewTabContent(QListWidgetItem*)));
connect(contextList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(setTabContent(QListWidgetItem*)));

The problem is that when I double click an item, I receive both setNewTabContent and setTabContent.

Do you have a solution for me ?

Thank you for your help !

Arsenic
7th August 2008, 22:28
I think you should use another signal, because a double click is two... clicks!
So, you'll probably get:
Click()
Click()
DoubleClick();

most likely. So try another signal that is just as good as a click.

spirit
8th August 2008, 06:59
I solve this problem using QTimer, but I think must be more elegate solution.

miraks
8th August 2008, 10:31
I solve this problem using QTimer, but I think must be more elegate solution.

I tried but without success :( Do you have an example ?

Thank you.

ankit17.ag
8th August 2008, 12:54
Hi,
You can try using some other signal like void currentItemChanged ( QListWidgetItem * item ) or void currentRowChanged ( int currentRow )]

spirit
8th August 2008, 13:56
if you inherit QTableView/QTreeView then I can post example, but if you don't then try another signals.

jpn
8th August 2008, 14:27
How about using modifiers to distinguish between two different actions, instead of single or double clicks? For example plain click vs. control + click.

miraks
8th August 2008, 14:50
How about using modifiers to distinguish between two different actions, instead of single or double clicks? For example plain click vs. control + click.

Hi,

Yes, I would like to do something like this:
click=open in current page
ctrl+click=open in a new page

but, I don't know how to done.

Do you know how to do ?

Thank you

jpn
8th August 2008, 16:52
See QApplication::keyboardModifiers().