PDA

View Full Version : QObject::connect: Cannot connect (null)::currentChanged on QTreeView



mut
27th June 2014, 17:19
Hello;

I'm writing Qt widget application. I'm having a QTreeView located on a QTabWidget, this QTabWidget itself located QMainWindow.

Here is my problem with row selection change on the QTreeView:

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);

QObject::connect(ui->MyTreeView->selectionModel(),
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(slot_MyTreeView_selectionChanged()));
}

Problem is that I'm getting:

QObject::connect: Cannot connect (null)::currentChanged(const QModelIndex &, const QModelIndex &) to MainWindow::slot_MyTreeView_selectionChanged()


Thanks;

Mut

yeye_olive
27th June 2014, 17:29
If I remember correctly, QAbstractView::selectionModel() is NULL until setModel() is called, and changes with every call to that method. Have you tried setting the model before establishing the connection?