-1

I am trying to figure out why my signal isn't connecting, I have the following code:

connect(mFileTree, SIGNAL(itemSelectionChanged()), this, SLOT(OnItemSelected()));

Yet it doesn't fire. mFileTree is a QTreeView there is a function called

void mlMainWindow::OnItemSelected()

That is being referenced in my header under

protected slots:
void OnItemSelected();

So I dunno what is going on here. Any advice?If this isn't the correct signal name or what have you, what is the correct signal and arguments? The QTreeView has the contents of a QFileSystemModel

Jalomba
  • 25
  • 6
  • 2
    [`QTreeView`](http://doc.qt.io/qt-5/qtreeview-members.html) doesn't have any signal (or member for that matter) called `itemSelectionChanged`. You should see a warning message at run time. Note that if you use the `Qt5` connect syntax you would get a compilation failure. – G.M. May 13 '17 at 15:01

1 Answers1

-1

If you want to be notified when the set of selected model indexes is changed you need to inherit from QTreeView and override the QTreeView::selectionChanged member...

virtual void selectionChanged (const QItemSelection &selected,
                               const QItemSelection &deselected) override
  {

    /*
     * The code you were going to put in
     * mlMainWindow::OnItemSelected should go here instead.
     */
  }
G.M.
  • 12,232
  • 2
  • 15
  • 18