Results 1 to 9 of 9

Thread: itemDoubleClicked and itemClicked

  1. #1
    Join Date
    Aug 2008
    Posts
    70
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default itemDoubleClicked and itemClicked

    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 !

  2. #2
    Join Date
    Jul 2007
    Posts
    30
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: itemDoubleClicked and itemClicked

    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.

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: itemDoubleClicked and itemClicked

    I solve this problem using QTimer, but I think must be more elegate solution.

  4. #4
    Join Date
    Aug 2008
    Posts
    70
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: itemDoubleClicked and itemClicked

    Quote Originally Posted by spirit View Post
    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.

  5. #5
    Join Date
    Jul 2008
    Location
    Mumbai, India
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: itemDoubleClicked and itemClicked

    Hi,
    You can try using some other signal like void currentItemChanged ( QListWidgetItem * item ) or void currentRowChanged ( int currentRow )]

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: itemDoubleClicked and itemClicked

    if you inherit QTableView/QTreeView then I can post example, but if you don't then try another signals.

  7. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: itemDoubleClicked and itemClicked

    How about using modifiers to distinguish between two different actions, instead of single or double clicks? For example plain click vs. control + click.
    J-P Nurmi

  8. The following user says thank you to jpn for this useful post:

    miraks (8th August 2008)

  9. #8
    Join Date
    Aug 2008
    Posts
    70
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: itemDoubleClicked and itemClicked

    Quote Originally Posted by jpn View Post
    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

  10. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: itemDoubleClicked and itemClicked

    J-P Nurmi

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.