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. C2061 - Syntax error
QtWS25 Last Chance

C2061 - Syntax error

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 4.9k 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.
  • M Offline
    M Offline
    MichelleK
    wrote on last edited by
    #1

    I am new at QT, so I apologize if this is an easy question, but I have typed in an example that I found that uses QListViewItem and for some reason it can not find it, even though I am including qlistview.h. Here is the header where I am getting the error:

    @
    #include <QMainWindow>
    #include <qlistview.h>
    #include <QtXml\QDomDocument>

    class OutlineTree : public QListView
    {
    Q_OBJECT
    public:
    OutlineTree( const QString filename, QWidget *parent = 0, const char *name = 0);
    ~OutlineTree();

    private:
    QDomDocument domTree;
    void getHeaderInformation(const QDomElement &header);
    void buildTree(QListViewItem * parentItem, const QDomElement &parentElement);
    };
    @

    And here is the .pro file, in case you find it useful:

    @
    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = DomTreeWithPart
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp
    OutlineTree.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui
    @

    Any thoughts or suggestions would be greatly appreciated.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You need to include QListViewItem, too.

      (Z(:^

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

        I did try that. It said there was no such file.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Oh sorry, I've mistaken that with QListWidgetItem, which does exist. Your example code might be wrong, then.

          (Z(:^

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            QListViewItem is from Qt 3, you should either update your code to use the Qt 4/5 classes or use Qt3Support but it's not a good idea since you seem to learn Qt.

            As a side note it's Qt, QT stands for Apple's QuickTime :)

            Hope it helps

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

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MichelleK
              wrote on last edited by
              #6

              I am using Qt 5.0.2. So, are you saying that QListViewItem is no longer valid in this version? If so, what would I use instead?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                QListViewItem was already no longer valid in Qt 4.

                Could you explain what you want to achieve so I can better help you ?

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

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  MichelleK
                  wrote on last edited by
                  #8

                  I was trying to read in an XML file using DOM and create a tree. I found an example online (evidently an old one) and tried to implement it for my file. The code in the class that is supposed to do everything looks like this:

                  @
                  OutlineTree::OutlineTree( const QString fileName, QWidget *parent, const char *name)
                  :QListView( parent, name)
                  {
                  QFile partFile("c:/qt experiments/database/parts/theFile.xml");
                  if (!partFile.open(QIODevice::ReadOnly)) {
                  QMessageBox::critical(0, tr("Critical Error"), tr("Parsing error for file"));
                  partFile.close();
                  return;
                  }
                  partFile.close();

                  //Get the header information from the DOM
                  QDomElement root = domTree.documentElement();
                  QDomNode node;
                  node = root.firstChild();
                  while ( !node.isNull()) {
                      if (node.isElement() && node.nodeName() == "PART") {
                          QDomElement part = node.toElement();
                          getHeaderInformation(part);
                          break;
                      }
                      node = node.nextSibling();
                  }
                  
                  //Create the tree view out of the DOM
                  node = root.firstChild();
                  while (!node.isNull()) {
                      if (node.isElement() && node.nodeName() == "PLY") {
                          QDomElement plys = node.toElement();
                          buildTree(0, plys);
                          break;
                      }
                      node = node.nextSibling();
                  }
                  

                  }

                  OutlineTree::~OutlineTree()
                  {

                  }

                  void OutlineTree::getHeaderInformation(const QDomElement &header)
                  {
                  //no children only attributes
                  }

                  void OutlineTree::buildTree(QListViewItem * parentItem, const QDomElement &parentElement)
                  {
                  QListViewItem * thisItem = 0;
                  QDomNode node = parentElement.firstChild();
                  while (!node.isNull()) {
                  //add a new list view item for the outline
                  if (parentItem == 0) {
                  if (node.isElement() && node,nodeName() == "PLY") {
                  thisItem = new QListViewItem(this, thisItem);
                  } else {
                  thisItem = new QListViewItem(parentItem, thisItem);
                  }
                  thisItem->setText(0, node.toElement().attribute("NAME"));
                  //recursive build of the tree
                  buildTree(thisItem, node.toElement());
                  }
                  node = node.nextSibling();
                  }
                  }
                  @

                  Maybe I should just find a more up-to-date example.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Then I would recommend the reading of Qt 5 doc's about QDomDocument and have look at the DOM Bookmark example. It covers exactly what you want

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

                    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