View Full Version : QListView icon double clicking
been_1990
27th April 2009, 13:31
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.
aamer4yu
27th April 2009, 19:25
Have a look at QAbstractItemView::clicked and QAbstractItemView::doubleClicked . Hope they do the work for you :)
been_1990
27th April 2009, 20:38
Have a look at QAbstractItemView::clicked and QAbstractItemView::doubleClicked . Hope they do the work for you :)
I tried those... I write this:
connect( ui->list, SIGNAL(QAbstractItemView::clicked() ), this, SLOT( run() ) );
This is what I get:
Object::connect: No such signal QListView::QAbstractItemView::clicked()
Object::connect: (sender name: 'list')
Object::connect: (receiver name: 'MainWindowClass')
I think I may be referencing the wrong class somewhere. But Im 100% sure I made a total mess with the connect signal-slot:o:D
Lykurg
28th April 2009, 10:24
connect( ui->list, SIGNAL(clicked(const QModelIndex &) ), this, SLOT( run(const QModelIndex &) ) );
//...
void YourClass::run(const QModelIndex &/*index*/)
{
//...
}
been_1990
28th April 2009, 12:52
connect( ui->list, SIGNAL(clicked(const QModelIndex &) ), this, SLOT( run(const QModelIndex &) ) );
//...
void YourClass::run(const QModelIndex &/*index*/)
{
//...
}
Does const QModelIndex &/*index*/ pass the index as a parameter to run(const QModelIndex &/*index*/)?
spirit
28th April 2009, 13:01
yes, but if you don't need this variable you can use this connection
connect( ui->list, SIGNAL(clicked(const QModelIndex &) ), this, SLOT( run() ) );
//...
void YourClass::run()
{
//...
}
been_1990
28th April 2009, 15:21
I actually need it a lot! How do I acess it? Do I write: const QModelIndex &myVariable ?
spirit
28th April 2009, 15:25
uncomment index in run or you can use QListView::currentIndex in run and don't pass QModelIndex in it.
been_1990
28th April 2009, 20:05
Thank you!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.