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. [solved]connect: No such slot QItemDelegate::invalidData()
Forum Updated to NodeBB v4.3 + New Features

[solved]connect: No such slot QItemDelegate::invalidData()

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.9k 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.
  • R Offline
    R Offline
    ras123
    wrote on last edited by
    #1

    Hi,
    I tried to connect signals from a object to the function declared in MyDeleagate which inherits QsqlRelationalTableDelegate
    @MyDelegate::MyDelegate(QObject *parent) : QSqlRelationalDelegate(parent)
    {
    blankCheck = new BlankCheck();
    reset();
    QObject::connect(blankCheck, SIGNAL(invalidEntry()), this, SLOT(invalidData()));
    }@

    @void MyDelegate::invalidData()
    {
    qDebug() << "Invalid Entry";
    }@

    and the class declaration is
    @class MyDelegate : public QSqlRelationalDelegate
    {
    public:
    MyDelegate(QObject *parent);
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
    const QModelIndex &index) const;
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
    void setModelData(QWidget *editor, QAbstractItemModel *model,
    const QModelIndex &index) const;
    void reset();

    private:
    BlankCheck *blankCheck;

    private slots:
    void invalidData();

    };@

    It is compiled, but while running the program, following error occurs

    Object::connect: No such slot QItemDelegate::invalidData() in mydelegate.cpp:15

    Why I can't connect these?

    Thanking You,
    Ras

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You forgot the Q_OBJECT macro in your declaration.

      Without this macro, signals, slots and introspection features will not work.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ras123
        wrote on last edited by
        #3

        Hi,
        Thank you, but when using Q_OBJECT marco following errors while compiling! Why?

        mydelegate.cpp:10: error: undefined reference to `vtable for MyDelegate'

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Did you re-run qmake after adding Q_OBJECT?

          1 Reply Last reply
          0
          • R Offline
            R Offline
            ras123
            wrote on last edited by
            #5

            Thanks Solved the issue.

            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