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. Custom QtChart promote
Qt 6.11 is out! See what's new in the release blog

Custom QtChart promote

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 768 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.
  • L Offline
    L Offline
    LISP
    wrote on last edited by
    #1

    I want to connect "QtChart" to "Custom widget".
    I downloaded the file in the path below.
    https://doc.qt.io/qt-5.12/qtcharts-zoomlinechart-example.html

    And I created a widget in my project and set "promote" as follows.

    Base class name: QWidget
    Promoted class name : ChartView
    Header file: chartview.h
    global include : unchecked

    but the result is a debugging error
    ui_mainwindow.h
    chartWidget = new ChartView(gBoxChart);

    The parameters of ChartView are created strangely.
    It seems to be affected by the ui's widget's parent.

    I modified ui_mainwindow.h myself, but when I rebuild it, it goes back to the old state.

    chartWidget = new ChartView(chart);
    I want to edit it, but it doesn't work.

    What did I do wrong?
    Thank you for reading my poor English.

    Pl45m4P 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #6

      Neither - create a ctor which takes QWidget *parent like the base class does: https://doc.qt.io/qt-5/qchartview.html#QChartView

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • L LISP

        I want to connect "QtChart" to "Custom widget".
        I downloaded the file in the path below.
        https://doc.qt.io/qt-5.12/qtcharts-zoomlinechart-example.html

        And I created a widget in my project and set "promote" as follows.

        Base class name: QWidget
        Promoted class name : ChartView
        Header file: chartview.h
        global include : unchecked

        but the result is a debugging error
        ui_mainwindow.h
        chartWidget = new ChartView(gBoxChart);

        The parameters of ChartView are created strangely.
        It seems to be affected by the ui's widget's parent.

        I modified ui_mainwindow.h myself, but when I rebuild it, it goes back to the old state.

        chartWidget = new ChartView(chart);
        I want to edit it, but it doesn't work.

        What did I do wrong?
        Thank you for reading my poor English.

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #2

        @LISP said in Custom QtChart promote:

        I modified ui_mainwindow.h myself, but when I rebuild it, it goes back to the old state.

        Because you dont need to nor should modify it yourself.

        but the result is a debugging error

        What error exactly?


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        2
        • L Offline
          L Offline
          LISP
          wrote on last edited by
          #3

          Thank you for your reply.
          ui_mainwindow.h
          chartWidget = new ChartView(gBoxChart); ////This code is an error.
          error : no matching function for call to 'ChartView::ChartView(QGroupBox*&) in file included from ...

          I don't think chartview can have gboxChart as a parameter.
          So I modified the ui_mainwindow.h myself.
          However, it is an auto-generated code, so when it is build, it is restored as it's original state.

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            You must modify your ChartView so it takes the QWidget parent as first parameter. Otherwise uic can not generate the code for it.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            L 1 Reply Last reply
            4
            • Christian EhrlicherC Christian Ehrlicher

              You must modify your ChartView so it takes the QWidget parent as first parameter. Otherwise uic can not generate the code for it.

              L Offline
              L Offline
              LISP
              wrote on last edited by
              #5

              @Christian-Ehrlicher
              Thanks for the good info.
              try one thing or another...
              ChartView(QChart *chart, QWidget *parent = 0);
              -> ChartView(QWidget *parent = 0, QChart *chart); ?
              Sorry.. :'(

              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #6

                Neither - create a ctor which takes QWidget *parent like the base class does: https://doc.qt.io/qt-5/qchartview.html#QChartView

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                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