Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QTableView selectionChanged

Tags:

qt

qt4

selection

I have a QTableView that I need to get the selectionChanged event from. I can't seem to get the connect working. I have:

MyWidget.h

...

protected slots:
 void slotLoadTransaction(const QItemSelection & selected, const QItemSelection & deselected);
private:
 QTableView table;

...

MyWidget.cpp

...

 connect(
  table->selectionModel(),
  SIGNAL(selectionChanged(const QItemSelection & selected, const QItemSelection & deselected)),
  this,
  SLOT(slotLoadTransaction(const QItemSelection & selected, const QItemSelection & deselected))
 );

...

At runtime, I get "No such Signal" errors.

like image 810
David Souther Avatar asked Mar 04 '10 00:03

David Souther


1 Answers

You need to remove the variable names from the SIGNAL and SLOT macros:

 connect(
  table->selectionModel(),
  SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
  SLOT(slotLoadTransaction(const QItemSelection &, const QItemSelection &))
 );

Connect is essentially looking at the function signature and the variable names confuse it.

like image 79
Kaleb Pederson Avatar answered Dec 13 '22 19:12

Kaleb Pederson