Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Connect try use slot of parent

Connect try use slot of parent

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 979 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr1Penguin
    wrote on last edited by
    #1

    Hi!

    header:
    @
    #ifndef BUHTABLEMODEL_H
    #define BUHTABLEMODEL_H

    #include <QStandardItemModel>

    class BuhTableModel : public QStandardItemModel
    {
    public:
    BuhTableModel(QObject *parent = 0);

    private slots:
    void changed(QStandardItem *item);
    };

    #endif // BUHTABLEMODEL_H
    @

    code:
    @
    #include "buhtablemodel.h"

    BuhTableModel::BuhTableModel(QObject parent)
    : QStandardItemModel(parent)
    {
    connect(this, SIGNAL(itemChanged(QStandardItem
    )), this, SLOT(changed(QStandardItem*)));
    }

    #include <QDebug>

    void BuhTableModel::changed(QStandardItem *item)
    {
    qDebug() << item->data().toString();
    }
    @

    Where is my mistake?

    QObject::connect: No such slot QStandardItemModel::changed(QStandardItem*)

    1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #2

      The class definition is missing the "Q_OBJECT":http://qt-project.org/doc/qt-5/qobject.html#Q_OBJECT macro.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mr1Penguin
        wrote on last edited by
        #3

        thanks!
        I completely forgot about that macro.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved