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. QtChart with Qt designer
Forum Updated to NodeBB v4.3 + New Features

QtChart with Qt designer

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 4.8k Views 2 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.
  • B Offline
    B Offline
    Bert59
    wrote on last edited by
    #1

    Hello,
    I'm new in Qt. I would like to use QtChart with Qt designer but the QChart widget is not available from Qt designer.
    After some research I found that I had to promote a widget to QChart. So I have the following in the Designer now d6a610df-595e-4eef-a839-578857ff9b40-image.png
    In the constructor I have the following

    m_chart = ui->chartView->chart();
    m_chartView = new QChartView(m_chart, this);
    m_xAxis = new QValueAxis;
    m_xAxis->setMax(1.0);
    m_xAxis->setMin(0.0);
    m_chart->addAxis(m_xAxis, Qt::AlignBottom);
    m_yAxis = new QValueAxis;
    m_yAxis->setMax(1.0);
    m_yAxis->setMin(0.0);
    m_chart->addAxis(m_yAxis, Qt::AlignLeft);
    

    The result looks like that
    d8949c96-d18d-4d0b-899f-0eaf3efa8bd0-image.png

    What can I do to see the graph completele?
    Thank you

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi
      You are creating a new CharView which has default size so that what you are seeing.
      you should use the one on the form
      ui->chartView
      and as @eyllanesc says delete the "new QChartView" line.

      Promotion is like a Type replacement, so Creator inserts the right type in the UI code
      even in the fom its other type used a placeholder.

      1 Reply Last reply
      0
      • eyllanescE Offline
        eyllanescE Offline
        eyllanesc
        wrote on last edited by
        #2

        delete m_chartView = new QChartView(m_chart, this); , is unnecesary.

        If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

        1 Reply Last reply
        1
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #3

          Hi
          You are creating a new CharView which has default size so that what you are seeing.
          you should use the one on the form
          ui->chartView
          and as @eyllanesc says delete the "new QChartView" line.

          Promotion is like a Type replacement, so Creator inserts the right type in the UI code
          even in the fom its other type used a placeholder.

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Bert59
            wrote on last edited by
            #4

            Thank you. Now the chart displays correctly.
            Do know why Qt Chart widget is not available in Qt Designer?

            mrjjM eyllanescE 2 Replies Last reply
            0
            • B Bert59

              Thank you. Now the chart displays correctly.
              Do know why Qt Chart widget is not available in Qt Designer?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @Bert59
              Hi
              Well its quite some work to make a plugin pr platform and maintain it pr release.
              Since QChart has many types of diagrams with its own properties, i guess
              they simply didn't think it was worth it as it also has many helper classes and
              would require a huge amount of code to be able to create such helper class
              "live" and also set properties on that. Like axis and such.
              https://doc.qt.io/qt-5/qtcharts-module.html

              Also it is using Qt Graphics View Framework and it does not use the same virtual system as QWidgets so
              that would also need to be added to the editor.

              But I'm just guessing :)

              Could be any reason but for Graphics View Framework, you must also set the scene in code and
              The designer cannot be used to set any properties of its items.

              So Maybe QChart just inherited that and providing Designer option for that is just very complicated bordering
              to impossible without heavy assumptions on behalf of the user.

              1 Reply Last reply
              0
              • B Bert59

                Thank you. Now the chart displays correctly.
                Do know why Qt Chart widget is not available in Qt Designer?

                eyllanescE Offline
                eyllanescE Offline
                eyllanesc
                wrote on last edited by
                #6

                @Bert59 If you want to use QChartView in Qt Designer without the promotion then you must compile and install the plugin, in this post I show the procedure: https://stackoverflow.com/questions/48362864/how-to-insert-qchartview-in-form-with-qt-designer/48363007#48363007

                If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

                1 Reply Last reply
                1
                • B Offline
                  B Offline
                  Bert59
                  wrote on last edited by
                  #7

                  Thank you for the link.
                  Unfortunately I couldn't find a dowload button on the linked page.
                  How can I download the files?

                  mrjjM 1 Reply Last reply
                  0
                  • B Bert59

                    Thank you for the link.
                    Unfortunately I couldn't find a dowload button on the linked page.
                    How can I download the files?

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    @Bert59
                    Hi
                    In chrome, you can use right click

                    alt text

                    Or you can go to front page
                    https://github.com/qt/qtcharts.git
                    and press the big green download.

                    and then take the files from the zip directly.

                    1 Reply Last reply
                    2

                    • Login

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