Results 1 to 9 of 9

Thread: QListView icon double clicking

  1. #1
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Post QListView icon double clicking

    How do I set Click, Doubleclick and rightClick in QListView? I want to create a very simple file browser but I cant find out what signal connect. Thanks.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QListView icon double clicking

    Have a look at QAbstractItemView::clicked and QAbstractItemView::doubleClicked . Hope they do the work for you

  3. #3
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Post Re: QListView icon double clicking

    Quote Originally Posted by aamer4yu View Post
    Have a look at QAbstractItemView::clicked and QAbstractItemView::doubleClicked . Hope they do the work for you
    I tried those... I write this:

    Qt Code:
    1. connect( ui->list, SIGNAL(QAbstractItemView::clicked() ), this, SLOT( run() ) );
    To copy to clipboard, switch view to plain text mode 

    This is what I get:

    Qt Code:
    1. Object::connect: No such signal QListView::QAbstractItemView::clicked()
    2. Object::connect: (sender name: 'list')
    3. Object::connect: (receiver name: 'MainWindowClass')
    To copy to clipboard, switch view to plain text mode 

    I think I may be referencing the wrong class somewhere. But Im 100% sure I made a total mess with the connect signal-slot
    Last edited by been_1990; 28th April 2009 at 00:22.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QListView icon double clicking

    Qt Code:
    1. connect( ui->list, SIGNAL(clicked(const QModelIndex &) ), this, SLOT( run(const QModelIndex &) ) );
    2. //...
    3. void YourClass::run(const QModelIndex &/*index*/)
    4. {
    5. //...
    6. }
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to Lykurg for this useful post:

    been_1990 (28th April 2009)

  6. #5
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Post Re: QListView icon double clicking

    Quote Originally Posted by Lykurg View Post
    Qt Code:
    1. connect( ui->list, SIGNAL(clicked(const QModelIndex &) ), this, SLOT( run(const QModelIndex &) ) );
    2. //...
    3. void YourClass::run(const QModelIndex &/*index*/)
    4. {
    5. //...
    6. }
    To copy to clipboard, switch view to plain text mode 
    Does const QModelIndex &/*index*/ pass the index as a parameter to run(const QModelIndex &/*index*/)?

  7. #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: QListView icon double clicking

    yes, but if you don't need this variable you can use this connection
    Qt Code:
    1. connect( ui->list, SIGNAL(clicked(const QModelIndex &) ), this, SLOT( run() ) );
    2. //...
    3. void YourClass::run()
    4. {
    5. //...
    6. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. #7
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView icon double clicking

    I actually need it a lot! How do I acess it? Do I write: const QModelIndex &myVariable ?

  9. #8
    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: QListView icon double clicking

    uncomment index in run or you can use QListView::currentIndex in run and don't pass QModelIndex in it.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  10. The following user says thank you to spirit for this useful post:

    been_1990 (28th April 2009)

  11. #9
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QListView icon double clicking

    Thank you!

Similar Threads

  1. Replies: 1
    Last Post: 17th May 2006, 00:23

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.