Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. I cant import and use Qtcharts in qml file

I cant import and use Qtcharts in qml file

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 3 Posters 5.2k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    PooyaSis
    wrote on last edited by
    #1

    qrc:/main.qml:3 plugin cannot be loaded for module "Qtcharts": Module namespace 'QtCharts' does not match import URI 'Qtcharts'

    this is the error..

    and these are my codes

    import QtQuick 2.8
    import QtQuick.Window 2.2
    import Qtcharts 2.2
    
    
    
    Window {
        visible: true
        visibility: "FullScreen"
    
        title: qsTr("Hello World")
    
    }
    
    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        if (engine.rootObjects().isEmpty())
            return -1;
    
        return app.exec();
    }
    
    
    1 Reply Last reply
    0
    • sierdzioS sierdzio

      @PooyaSis said in I cant import and use Qtcharts in qml file:

      import Qtcharts 2.2

      import QtCharts 2.2

      Uppercase "c" :-)

      P Offline
      P Offline
      PooyaSis
      wrote on last edited by
      #3

      @sierdzio
      thanks a lot.
      but why my Qt doesn't auto complete?!
      I mean, I should write the import QtCharts 2.2 my self!

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

        @PooyaSis said in I cant import and use Qtcharts in qml file:

        import Qtcharts 2.2

        import QtCharts 2.2

        Uppercase "c" :-)

        (Z(:^

        P 1 Reply Last reply
        1
        • sierdzioS sierdzio

          @PooyaSis said in I cant import and use Qtcharts in qml file:

          import Qtcharts 2.2

          import QtCharts 2.2

          Uppercase "c" :-)

          P Offline
          P Offline
          PooyaSis
          wrote on last edited by
          #3

          @sierdzio
          thanks a lot.
          but why my Qt doesn't auto complete?!
          I mean, I should write the import QtCharts 2.2 my self!

          sierdzioS 1 Reply Last reply
          0
          • P PooyaSis

            @sierdzio
            thanks a lot.
            but why my Qt doesn't auto complete?!
            I mean, I should write the import QtCharts 2.2 my self!

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #4

            @PooyaSis Qt Creator does auto complete QML imports for you, just type the first 4 characters and it should display the auto fill context menu. Unless it does not see the QtCharts module somehow. Have you installed it using the official installer?

            (Z(:^

            P 1 Reply Last reply
            0
            • sierdzioS sierdzio

              @PooyaSis Qt Creator does auto complete QML imports for you, just type the first 4 characters and it should display the auto fill context menu. Unless it does not see the QtCharts module somehow. Have you installed it using the official installer?

              P Offline
              P Offline
              PooyaSis
              wrote on last edited by PooyaSis
              #5

              @sierdzio
              It's not displaying the auto fill for QtCharts 2.2!!! but it can recognize it...
              I used MaintenanceTool for installing QtCharts ...
              @mrjj
              still I have problem with QtCharts

              main.cpp

              #include <QGuiApplication>
              #include <QQmlApplicationEngine>
              
              int main(int argc, char *argv[])
              {
                  QGuiApplication app(argc, argv);
              
                  QQmlApplicationEngine engine;
                  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
                  if (engine.rootObjects().isEmpty())
                      return -1;
              
                  return app.exec();
              }
              
              

              main.qml

              import QtQuick 2.6
              import QtQuick.Window 2.2
              import QtCharts 2.2
              
              Window {
                  visible: true
                  width: 640
                  height: 480
                  title: qsTr("Hello World")
              
                  ChartView {
                      id: chartView
                      backgroundColor: "transparent"
                      legend.visible: false
              
                      ValueAxis {
                          id: valueAxisX
                          min: 0
                          max: maxNumOfTempReadings + 1
                          visible: false
                      }
              
                      ValueAxis {
                          id: valueAxisY
                          min: minimum
                          max: maximum
                          visible: false
                      }
              
                      LineSeries {
                          id: avgTempSeries
                          axisX: valueAxisX
                          axisY: valueAxisY
                          color: chartColor
                      }
                  }
              
              }
              
              

              0_1502778257334_error.png

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Abin
                wrote on last edited by
                #6

                For QtCharts, in documentation it says clearly:

                Note: Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View Framework for drawing, QApplication must be used. The project created with the wizard is usable with Qt Charts after the QGuiApplication is replaced with QApplication.

                1 Reply Last reply
                1

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved