ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
C++ Qt QlistView signals
************************
My problem is about knowing in what 'item' of a ListView the user has clicked.
I tried with the following program (3 modules plus a Widget from QtDesigner (ui_wex50.h).)
QWidget *mywindow = new QWidget;
QListWidget *mylistWidget = new QListWidget(this);
mylistWidget->setGeometry(50,10,40,400);
new QListWidgetItem(tr("A"), mylistWidget);
new QListWidgetItem(tr("B"), mylistWidget);
new QListWidgetItem(tr("C"), mylistWidget);
new QListWidgetItem(tr("D"), mylistWidget);
new QListWidgetItem(tr("F"), mylistWidget);
new QListWidgetItem(tr("G"), mylistWidget);
new QListWidgetItem(tr("H"), mylistWidget);
new QListWidgetItem(tr("I"), mylistWidget);
new QListWidgetItem(tr("J"), mylistWidget);
new QListWidgetItem(tr("K"), mylistWidget);
new QListWidgetItem(tr("L"), mylistWidget);
new QListWidgetItem(tr("M"), mylistWidget);
new QListWidgetItem(tr("N"), mylistWidget);
new QListWidgetItem(tr("O"), mylistWidget);
new QListWidgetItem(tr("P"), mylistWidget);
new QListWidgetItem(tr("Q"), mylistWidget);
new QListWidgetItem(tr("R"), mylistWidget);
new QListWidgetItem(tr("S"), mylistWidget);
new QListWidgetItem(tr("T"), mylistWidget);
new QListWidgetItem(tr("U"), mylistWidget);
new QListWidgetItem(tr("V"), mylistWidget);
new QListWidgetItem(tr("X"), mylistWidget);
new QListWidgetItem(tr("Y"), mylistWidget);
new QListWidgetItem(tr("W"), mylistWidget);
new QListWidgetItem(tr("Z"), mylistWidget);
O.K. you have more possibilities :
-take the signal < selectionChanged( QListViewItem * ) > so you get the item the user changed to.
-take the signal < selectionChanged () > and in the member you connected to read then what the current item is < QListViewItem * currentItem () >
-take the signal < void clicked ( QListViewItem * item ) but that means any mouse click, so you have to look what mousebutton is pressed.
It looks like you don't take QT-Designer to create your Widgets. There you get presented what signals you can use and where you can connect to.
The error you get is often because of signals with names, strings as value or the connected member is not in the same class and below. With parent-> you can connect to overlaying Widgets, just parents.
Thanks a lot.
I'm goig to study your proposition.
I'm, newcomer to linux and Qt (I'm learning by myself), even I have a medium experience in C++ Borland Builder for Windows. The Designer module refers itself to others details of my widget that I didn't include to resume the problem.
Thanks and Have a Happy New Year.
Quote:
Originally Posted by bastl
Hello.
O.K. you have more possibilities :
-take the signal < selectionChanged( QListViewItem * ) > so you get the item the user changed to.
-take the signal < selectionChanged () > and in the member you connected to read then what the current item is < QListViewItem * currentItem () >
-take the signal < void clicked ( QListViewItem * item ) but that means any mouse click, so you have to look what mousebutton is pressed.
It looks like you don't take QT-Designer to create your Widgets. There you get presented what signals you can use and where you can connect to.
The error you get is often because of signals with names, strings as value or the connected member is not in the same class and below. With parent-> you can connect to overlaying Widgets, just parents.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.