Please nominate your Qt Champions for 2021!

why do I need to claim this class in h file?

  • My h file is like this:

    • #ifndef WINDOW_H
      #define WINDOW_H
      #include <QMainWindow>
      #include <QUrl>
      #include <QWebElement>
      class QTreeWidgetItem; //====================================> why do I need this line?
      #include "ui_window.h"
      class Window : public QMainWindow, private Ui::Window
      Window(QWidget *parent = 0);
      void setUrl(const QUrl &url);
      public slots:
      void on_webView_loadFinished();
      void examineChildElements(const QWebElement &parentElement,
      QTreeWidgetItem *parentItem);

  • It's a forward declaration. (a bit more about it here and here

  • @David.G Thank you!

Log in to reply