Results 1 to 2 of 2

Thread: QObject::connect: Cannot connect (null)::currentChanged on QTreeView

  1. #1
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Question QObject::connect: Cannot connect (null)::currentChanged on QTreeView

    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

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QObject::connect: Cannot connect (null)::currentChanged on QTreeView

    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?

Similar Threads

  1. Issue with QObject::connect
    By fish_sticks in forum Qt Programming
    Replies: 10
    Last Post: 3rd March 2012, 10:24
  2. QObject::connect
    By littlepig in forum Newbie
    Replies: 4
    Last Post: 9th February 2011, 13:08
  3. [Help] QObject::connect
    By vinny gracindo in forum Newbie
    Replies: 3
    Last Post: 20th October 2009, 14:26
  4. QObject::connect: No such slot !?!
    By Mystical Groovy in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 19:31
  5. Replies: 4
    Last Post: 10th November 2006, 16:38

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.