0

I'm using OpenGl in QTCreator.

I'm having difficulty linking my tree widget (in the UI) and the associated header/cpp files. I'm pretty sure my header declaration is correct. Is there anything special I need to do to perform the linking?

The tree widget has already been promoted to myTree

#ifndef MYTREE_H
#define MYTREE_H

#include <QTreeWidget>

class myTree: public QTreeWidget {

    Q_OBJECT

public:
    myTree(QWidget*);
    myTree();
    ~myTree();

public slots:
    void receiveroot(QTreeWidgetItem*);

};

#endif
cppguy
  • 3,611
  • 2
  • 21
  • 36
AmazingVal
  • 301
  • 4
  • 11

1 Answers1

0

After you've added this file to the SOURCES list in the .pro file, you have to re-run qmake on the project, then build it. Your problem is, most likely, due to moc not being run on this file. Your default constructor is unnecessary, there should be a default nullptr parameter given to the parent:

public:
  myTree(QWidget* parent = nullptr);

I presume that your receiveRoot method looks somewhat like the below?

Q_SLOT void receiveRoot(QTreeWidgetItem * item) {
  QModelIndex index = indexFromItem(item);
  setRootIndex(index);
}     
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313