edit
SOLVED, i just forgot to initializefound_users
I have two QListWidget into a single window.
The one on the left is the list of all the users of my database.
The one on the right displays a subset of accounts related to a query result.
I want the selection on the right to be reflected on the left.
For example if i have on the left
usr1
usr2
usr3
usr4
and I select "usr3" on the right list, it should be trigger the selection of "usr3" on the left.
Here's the code:
.h
class win_admin : public QWidget{
Q_OBJECT
private:
QListWidget* all_users;
QListWidget* found_users;
public:
[...]
public slots:
void send_to_main_list();
[...]
}
.cpp
connect (found_users, SIGNAL(itemSelectionChanged()), this, SLOT(send_to_main_list()));
[...]
void win_admin::send_to_main_list() {
QString usn=found_users->currentItem()->text();
int i=0;
while (i<all_users->count() && all_users->item(i)->text()!=usn) {
++i;
}
if (i<all_users->count()) if (i<all_users->count()) all_users->setCurrentRow(i);
}
that's not working for me when i select something on the right they say:
QObject::connect: Cannot connect (null)::itemSelectionChanged() to win_admin::send_to_main_list()
i hope, the info i gave was enought.
The error message you get shows the reason why connect()
call has failed.
QObject::connect: Cannot connect (null)::itemSelectionChanged() to win_admin::send_to_main_list()
It shows that sender QListWidget* found_users
passed to connect()
call is null.
You should probably have forgotten to initialize found_users
.