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. Undefined reference error

Undefined reference error

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 2.1k Views
  • 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.
  • G Offline
    G Offline
    gabor53
    wrote on 28 Sept 2017, 15:17 last edited by
    #1

    Hi,
    I have this setItemDelegateForColumn line:

     QSqlTableModel* fixModel = new QSqlTableModel(this);
      fixModel->setTable ("Items");
      fixModel->setEditStrategy (QSqlTableModel::OnRowChange);
      fixModel->setSort (2, Qt::DescendingOrder);
    
      fixModel->select ();
    
      ui->tableView_Fix->setModel (fixModel);
    
      ui->tableView_Fix->setItemDelegateForColumn (4, new MaterialDelegate(this));
      ui->tableView_Fix->setItemDelegateForColumn(2, new FixViewDelegate(this));
      ui->tableView_Fix->setItemDelegateForColumn (3, new WhatFixViewDelegate(this));
    
    

    Since I added MaterialDelegate I get this error:
    undefined reference to `MaterialDelegate::MaterialDelegate(QObject)'*
    I read it might be a bug, but how can I go around it and assign the delegate?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 28 Sept 2017, 15:47 last edited by
      #2

      @gabor53 said in Undefined reference error:

      MaterialDelegate::MaterialDelegate(QObject)'

      It says it dont have such constructor.

      Show the class definition.

      G 1 Reply Last reply 28 Sept 2017, 15:58
      0
      • M mrjj
        28 Sept 2017, 15:47

        @gabor53 said in Undefined reference error:

        MaterialDelegate::MaterialDelegate(QObject)'

        It says it dont have such constructor.

        Show the class definition.

        G Offline
        G Offline
        gabor53
        wrote on 28 Sept 2017, 15:58 last edited by
        #3

        @mrjj
        materialdelegate.h:

        #ifndef MATERIALDELEGATE_H
        #define MATERIALDELEGATE_H
        
        #include <QComboBox>
        #include <QObject>
        #include <QString>
        #include <QSqlQuery>
        #include <QStyledItemDelegate>
        #include <QVBoxLayout>
        #include <QWidget>
        
        class MaterialDelegate : public QStyledItemDelegate {
          Q_OBJECT
        
         public:
          QSqlDatabase db;
        
          explicit MaterialDelegate(QObject* parent = Q_NULLPTR);
        
          QWidget*   createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const;
          void setEditorData(QWidget* editor, const QModelIndex& index) const;
          void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const;
          void setModelData(QWidget* editor, QAbstractItemModel* fixModel, const QModelIndex& index) const;
        
        
         signals:
        
         public slots:
        };
        
        #endif // MATERIALDELEGATE_H
        
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 28 Sept 2017, 16:05 last edited by
          #4

          Hi
          seems fine.
          Delete all files in your build folder and run qmake and rebuild all.

          G 1 Reply Last reply 28 Sept 2017, 16:14
          0
          • M mrjj
            28 Sept 2017, 16:05

            Hi
            seems fine.
            Delete all files in your build folder and run qmake and rebuild all.

            G Offline
            G Offline
            gabor53
            wrote on 28 Sept 2017, 16:14 last edited by
            #5

            @mrjj
            Same error.

            M 1 Reply Last reply 28 Sept 2017, 16:27
            0
            • G gabor53
              28 Sept 2017, 16:14

              @mrjj
              Same error.

              M Offline
              M Offline
              m.sue
              wrote on 28 Sept 2017, 16:27 last edited by
              #6

              Hi @gabor53

              this is probably derived from a QObject * and you assume implicit conversion. But the explicit keyword in the MaterialDelegatecontructor does not allow for it: http://en.cppreference.com/w/cpp/language/explicit

              -Michael.

              1 Reply Last reply
              3
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 28 Sept 2017, 21:33 last edited by
                #7

                Hi,

                Might be a silly question but did you implement that constructor ?

                On a side note, there's not need for that db member variable.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                G 1 Reply Last reply 29 Sept 2017, 02:12
                0
                • S SGaist
                  28 Sept 2017, 21:33

                  Hi,

                  Might be a silly question but did you implement that constructor ?

                  On a side note, there's not need for that db member variable.

                  G Offline
                  G Offline
                  gabor53
                  wrote on 29 Sept 2017, 02:12 last edited by
                  #8

                  @SGaist
                  Hi,
                  Yes, implemented it.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    gabor53
                    wrote on 29 Sept 2017, 03:06 last edited by
                    #9

                    I completely deleted and recreated materialdelegate and now it work. Still don't know what was wrong with the previous file.

                    1 Reply Last reply
                    0

                    1/9

                    28 Sept 2017, 15:17

                    • Login

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