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. QChart: invalid use of incomplete type 'class QChartView'
Forum Updated to NodeBB v4.3 + New Features

QChart: invalid use of incomplete type 'class QChartView'

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 940 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.
  • A Offline
    A Offline
    Alexander Maltsev
    wrote on last edited by Alexander Maltsev
    #1

    Hi,
    I did all recommendations I have found.
    I installed qchart module with

    sudo apt install libqt5charts5-dev.
    I added
    QT += charts
    to my project.
    The header file qchartview.h is found without problems.
    Still get compiler error:
    invalid use of incomplete type 'class QChartView'
    What can be wrong?

    Just a simplified C++ code for understanding

    #include <QChartView>
    QChartView m_chartView = new QChartView(centralTabWidget);

    jsulmJ 1 Reply Last reply
    0
    • A Alexander Maltsev

      Hi,
      I did all recommendations I have found.
      I installed qchart module with

      sudo apt install libqt5charts5-dev.
      I added
      QT += charts
      to my project.
      The header file qchartview.h is found without problems.
      Still get compiler error:
      invalid use of incomplete type 'class QChartView'
      What can be wrong?

      Just a simplified C++ code for understanding

      #include <QChartView>
      QChartView m_chartView = new QChartView(centralTabWidget);

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Alexander-Maltsev Did you try a complete rebuild: delete build folder, run qmake and build?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alexander Maltsev
        wrote on last edited by
        #3

        Yes I did. Exactly the same error

        jsulmJ 1 Reply Last reply
        0
        • A Alexander Maltsev

          Yes I did. Exactly the same error

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Alexander-Maltsev Is it possible that you're using QChartView somewhere else where you do not include the header file?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Alexander Maltsev
            wrote on last edited by Alexander Maltsev
            #5

            I include <QChartView> directly in mainwindow.cpp.
            The code line QChartView m_chartView = new QChartView(centralTabWidget); in mainwindow.cpp causes the compiler error I mentioned above

            Pardon, the line is
            QChartView *m_chartView = new QChartView(centralTabWidget);

            JonBJ 1 Reply Last reply
            0
            • A Alexander Maltsev

              I include <QChartView> directly in mainwindow.cpp.
              The code line QChartView m_chartView = new QChartView(centralTabWidget); in mainwindow.cpp causes the compiler error I mentioned above

              Pardon, the line is
              QChartView *m_chartView = new QChartView(centralTabWidget);

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @Alexander-Maltsev said in QChart: invalid use of incomplete type 'class QChartView':

              The code line QChartView m_chartView = new QChartView(centralTabWidget);

              Pardon, the line is

              QChartView *m_chartView = new QChartView(centralTabWidget)

              Please use copy & paste when quoting from your code, we spend too much time chasing down issues when people just "type" what they (think they) have in code only to later discover they actually have something else like here!

              Do you have a .h file declaring your class? Assuming so, show that and what you do about declaring QChartView there prior to your use of QChartView anywhere inside it. Read again what @jsulm has written "Is it possible that you're using QChartView somewhere else". The error message names a file and a line number: make 100% certain that is on your QChartView *m_chartView = new QChartView(centralTabWidget); statement and not somewhere else?

              A 1 Reply Last reply
              0
              • A Offline
                A Offline
                Alexander Maltsev
                wrote on last edited by
                #7

                This is the solution

                QtCharts::QChartView *m_chartView = new QtCharts::QChartView(centralTabWidget);
                

                Sorry for inconveneience

                1 Reply Last reply
                0
                • JonBJ JonB

                  @Alexander-Maltsev said in QChart: invalid use of incomplete type 'class QChartView':

                  The code line QChartView m_chartView = new QChartView(centralTabWidget);

                  Pardon, the line is

                  QChartView *m_chartView = new QChartView(centralTabWidget)

                  Please use copy & paste when quoting from your code, we spend too much time chasing down issues when people just "type" what they (think they) have in code only to later discover they actually have something else like here!

                  Do you have a .h file declaring your class? Assuming so, show that and what you do about declaring QChartView there prior to your use of QChartView anywhere inside it. Read again what @jsulm has written "Is it possible that you're using QChartView somewhere else". The error message names a file and a line number: make 100% certain that is on your QChartView *m_chartView = new QChartView(centralTabWidget); statement and not somewhere else?

                  A Offline
                  A Offline
                  Alexander Maltsev
                  wrote on last edited by
                  #8

                  @JonB If I write the error message is caused exactly by the line I show then it is so. I apologized for my previous mistake. I beg your pardon for spending too much valuable time and thank you very much for your assistance

                  JonBJ 1 Reply Last reply
                  0
                  • A Alexander Maltsev

                    @JonB If I write the error message is caused exactly by the line I show then it is so. I apologized for my previous mistake. I beg your pardon for spending too much valuable time and thank you very much for your assistance

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #9

                    @Alexander-Maltsev
                    I was just trying to help, getting the facts straight. I am glad you have it working now.

                    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