Results 1 to 3 of 3

Thread: connect not working with manually created object

  1. #1
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default connect not working with manually created object

    QObject::connect isn't working for me if I create the object in C++. It does work if I add it in QT designer though. Doesn't make sense. What am I doing wrong?

    CPP:

    Qt Code:
    1. QTableView *tableWidget = new QTableView(this);
    2. tableWidget->setObjectName(QString::fromUtf8("tableView"));
    3. tableWidget->setModel(&model);
    4. tableWidget->setAttribute(Qt::WA_DeleteOnClose, true);
    5. tableWidget->setSelectionMode(QAbstractItemView::SingleSelection);
    6. tableWidget->setSelectionBehavior(QAbstractItemView::SelectColumns);
    7. QObject::connect(tableWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(on_tableView_clicked(QModelIndex)));
    To copy to clipboard, switch view to plain text mode 

    Header file:
    Qt Code:
    1. public slots:
    2. void on_tableView_clicked(QModelIndex idx);
    To copy to clipboard, switch view to plain text mode 

    When I run it it says:

    QMetaObject::connectSlotsByName: No matching signal for on_tableView_clicked(QModelIndex)

  2. #2
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: connect not working with manually created object

    I see the problem. It works if click a cell in the table, but not the column header, which is what I want. Is there a signal for this?

  3. #3
    Join Date
    Aug 2009
    Posts
    56
    Thanks
    14
    Thanked 1 Time in 1 Post

    Default Re: connect not working with manually created object

    Found it, it's sectionClicked on the horizontalHeader()

Similar Threads

  1. A signal/slot connect isn't working.
    By Daimonie in forum Qt Programming
    Replies: 6
    Last Post: 15th February 2009, 23:55
  2. Connect not working
    By xgoan in forum Qt Programming
    Replies: 4
    Last Post: 24th July 2006, 12:27

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.