May 1, 2012

jscDev jscDev
Lab Rat
4 posts

No matching signal for on_currentChanged with QItemSelectionModel

 

Running Qt 4.8 on CentOS. This message is displayed when the dialog is displayed:
QMetaObject::connectSlotsByName: No matching signal for on_currentChanged(QModelIndex,QModelIndex)

However, the dialog operates as expected. When an item is selected with keyboard or mouse, the correct slot is called with the correct data.

In dialog.h:

  1.    QStandardItemModel* scenarioListModel;
  2.    QItemSelectionModel* selectionModel;
  3. private slots:
  4.     void on_currentChanged (  const QModelIndex& current,  const QModelIndex& previous );

In dialog.cpp:
Constructor:

  1.        ui.setupUi(this);
  2.      ......
  3.  selectionModel = ui.scenarioListTableView->selectionModel();
  4.  
  5.  connect (selectionModel, SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)),
  6.           this, SLOT(on_currentChanged( const QModelIndex&, const QModelIndex& )));
  7. .....
  8. void OpenScenarioDialog::on_currentChanged ( const QModelIndex& current, const QModelIndex& previous )
  9. {
  10.   QString selectedScenario = current.data().toString();  // this has the current selection
  11. }

Other signals and slots on this dialog (and others) work fine. Selection mode is set to SingleSelection. Selection Behavior is SelectRows. QTableView has three columns.

What am I missing? Thanks for your time and assistance.

[EDIT: code formatting, please use @-tags, Volker]

2 replies

May 1, 2012

1+1=10 1+1=10
Hobby Entomologist
643 posts

http://qt-project.org/doc/qt-4.8/qmetaobject.html#connectSlotsByName

So don’t create slots in such pattern

  1. on_XXXX

If you do not intend to use “auto connection”.

May 1, 2012

jscDev jscDev
Lab Rat
4 posts

Would like to use the auto connection, but without the connect, the slot doesn’t get called. Other auto connection slots on other dialogs work fine. Is there something else to do to get auto connect to work with the QItemSelectionModel?

 
  ‹‹ Impossible to use repaint() again      Problem with displaying % sign in a QString ››

You must log in to post a reply. Not a member yet? Register here!