1

I am getting a mysterious error trying to subclass QTreeWidget. Below is code from the relevant files. In QtDesigner, I have promoted a QTreeWidget to a treeWidget, but I get the following error:

Error 1 error C2061: syntax error : identifier 'treeWidget' Visual Studio 2010\Projects\hw2\QTOpenGL\GeneratedFiles\ui_opengldemo.h 72 1 QTOpenGL

I have been told not to edit code in the ui_ files, so I'm assuming this problem can be solved without going in there. Any ideas? Does the code below give enough information to solve this issue? Thanks.

**treeWidget.h:**

#ifndef TREEWIDGET
#define TREEWIDGET

#include <QTreeWidget>
#include "gNode.h"
class treeWidget :
    public QTreeWidget
{
    Q_OBJECT
public:
    treeWidget(QWidget*);
    ~treeWidget(void);
public slots:
    void topLevelItem(gNode* node);
};

#endif


**treeWidget.cpp**
#include "treeWidget.h"


treeWidget::treeWidget(QWidget* parent) : QTreeWidget(parent)
{
}


treeWidget::~treeWidget(void)
{
}

void treeWidget::topLevelItem(gNode* node){
    addTopLevelItem(node);
}
George
  • 343
  • 2
  • 15
  • Can you post the exact error message ? – Mahesh Feb 14 '12 at 04:06
  • I did. That's pretty much all it says. This message is repeated verbatim three times referencing the same line number. 1>C:\Users\\Documents\Visual Studio 2010\Projects\hw2\QTOpenGL\GeneratedFiles\ui_opengldemo.h(72): error C2061: syntax error : identifier 'treeWidget' 1> opengldemo.cpp – George Feb 14 '12 at 04:12
  • The `ui_` header files usually come from using the Qt designer to make the GUI. You are referencing treeWidget in the GUI, so the problem probably lies there. – Alexander Kondratskiy Feb 14 '12 at 05:51
  • When promoting the QTreeWidget in the designer, did you give it the right path to `treeWidget.h`? – cmannett85 Feb 14 '12 at 07:31
  • the topLevelItem is not virtual. – Neox Feb 14 '12 at 08:57
  • cbamber85: yes, i did that in the "promote" dialog. neox: i tried declaring the topLevelItem(gNode*) function as virtual in the .h file, and I received the same error. – George Feb 14 '12 at 14:45

1 Answers1

0

Figured it out. Changed name to myTreeWidget from treeWidget and all works fine.

George
  • 343
  • 2
  • 15