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. how to override qtcharts QBarSeries?
Forum Updated to NodeBB v4.3 + New Features

how to override qtcharts QBarSeries?

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 5 Posters 163 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.
  • jsulmJ jsulm

    @crane_jiang said in how to override qtcharts QBarSeries?:

    so I try to rewrite the codes in the source code

    In that case you have to build and install this Qt modue.
    Did you do that?

    C Offline
    C Offline
    crane_jiang
    wrote last edited by
    #3

    @jsulm
    yes, I rebuild the qt library, we are developing embedded qt applications and use our customed qt libs.
    we just want to not select useless modules, but not to changed default libs source.
    so we think override in our application is better than modify qt lib source.

    jsulmJ 1 Reply Last reply
    0
    • C crane_jiang

      @jsulm
      yes, I rebuild the qt library, we are developing embedded qt applications and use our customed qt libs.
      we just want to not select useless modules, but not to changed default libs source.
      so we think override in our application is better than modify qt lib source.

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

      @crane_jiang Not sure I understand you. If you change Qt code you have to rebuild the Qt module where this code is located. How else would this work?
      If you rebuild the Qt module and it still does not work then make sure you properly installed your custom built module.

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

      C 1 Reply Last reply
      1
      • jsulmJ jsulm

        @crane_jiang Not sure I understand you. If you change Qt code you have to rebuild the Qt module where this code is located. How else would this work?
        If you rebuild the Qt module and it still does not work then make sure you properly installed your custom built module.

        C Offline
        C Offline
        crane_jiang
        wrote last edited by crane_jiang
        #5

        @jsulm
        I make changes in qt lib just to see if it can work, setLabelsFormat() can show customed bar labels with set/category more than just value.
        but I don't want to use this way seriously.

        I want to do this by override official QHorizontalStackedBarSeries codes.
        I find the related codes are under qt-everywhere-src-5.15.12/qtcharts/src/charts/barchart/horizontal/stacked/.
        (1) horizontalstackedbarchartitem_p.h
        (2) qhorizontalstackedbarseries.h
        (3) qhorizontalstackedbarseries_p.h
        (4) horizontalstackedbarchartitem.cpp
        (5) qhorizontalstackedbarseries.cpp
        I want to replace these files with my own ones, myhorizontalstackedbarchartitem_p.h myqhorizontalstackedbarseries.h myqhorizontalstackedbarseries_p.h myhorizontalstackedbarchartitem.cpp myqhorizontalstackedbarseries.cpp, respectively.
        and then use my customed class myQHorizontalStackedBarSeriesto whose generateLabelsText() support display bar labels to replace official QHorizontalStackedBarSeries.
        and I do have add "QT += charts-private" in project.pro file.

        I can't upload my override codes in reply,

        so I upload it to my space link my qtcharts override codes

        there are several build errors such as

        undefined reference to `__imp__ZTVN8QtCharts29myQHorizontalStackedBarSeriesE'
        undefined reference to `__imp__ZTVN8QtCharts36myQHorizontalStackedBarSeriesPrivateE'
        

        I don't know how to fix these errors.
        thank you

        jsulmJ JonBJ 2 Replies Last reply
        0
        • C crane_jiang

          @jsulm
          I make changes in qt lib just to see if it can work, setLabelsFormat() can show customed bar labels with set/category more than just value.
          but I don't want to use this way seriously.

          I want to do this by override official QHorizontalStackedBarSeries codes.
          I find the related codes are under qt-everywhere-src-5.15.12/qtcharts/src/charts/barchart/horizontal/stacked/.
          (1) horizontalstackedbarchartitem_p.h
          (2) qhorizontalstackedbarseries.h
          (3) qhorizontalstackedbarseries_p.h
          (4) horizontalstackedbarchartitem.cpp
          (5) qhorizontalstackedbarseries.cpp
          I want to replace these files with my own ones, myhorizontalstackedbarchartitem_p.h myqhorizontalstackedbarseries.h myqhorizontalstackedbarseries_p.h myhorizontalstackedbarchartitem.cpp myqhorizontalstackedbarseries.cpp, respectively.
          and then use my customed class myQHorizontalStackedBarSeriesto whose generateLabelsText() support display bar labels to replace official QHorizontalStackedBarSeries.
          and I do have add "QT += charts-private" in project.pro file.

          I can't upload my override codes in reply,

          so I upload it to my space link my qtcharts override codes

          there are several build errors such as

          undefined reference to `__imp__ZTVN8QtCharts29myQHorizontalStackedBarSeriesE'
          undefined reference to `__imp__ZTVN8QtCharts36myQHorizontalStackedBarSeriesPrivateE'
          

          I don't know how to fix these errors.
          thank you

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote last edited by
          #6

          @crane_jiang said in how to override qtcharts QBarSeries?:

          I want to replace these files with my own ones

          Where? In your project source tree? How should QtCharts module know anything about your own implementation of that class?

          You either subclass QHorizontalStackedBarSeries, or, if it does not help, alter Qt implementation and rebuild the Qt module.

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

          C 1 Reply Last reply
          1
          • C Offline
            C Offline
            crane_jiang
            wrote last edited by crane_jiang
            #7

            @jsulm
            yes, I add these 5 myxxx.h/cpp in my project tree, rather than change official source code directly.
            does it matters?

            and I have valid company qt-license,
            how can I connect official support engineer for help?

            jsulmJ Christian EhrlicherC 2 Replies Last reply
            0
            • C crane_jiang

              @jsulm
              yes, I add these 5 myxxx.h/cpp in my project tree, rather than change official source code directly.
              does it matters?

              and I have valid company qt-license,
              how can I connect official support engineer for help?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote last edited by
              #8

              @crane_jiang Here I guess: https://www.qt.io/qt-support/

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

              1 Reply Last reply
              0
              • jsulmJ jsulm

                @crane_jiang said in how to override qtcharts QBarSeries?:

                I want to replace these files with my own ones

                Where? In your project source tree? How should QtCharts module know anything about your own implementation of that class?

                You either subclass QHorizontalStackedBarSeries, or, if it does not help, alter Qt implementation and rebuild the Qt module.

                C Offline
                C Offline
                crane_jiang
                wrote last edited by crane_jiang
                #9

                @jsulm said in how to override qtcharts QBarSeries?:

                How should QtCharts module know anything about your own implementation of that class?

                yes, that's the point. the error message seems it don't know how to new the class, class is in-complete...
                I tried to make my class myqhorizontalstackedbarseries as child of qhorizontalstackedbarseries, but the Constructor ~Constructor() become complex, and get lots of errors。 so I make myqhorizontalstackedbarseries as brothers of qhorizontalstackedbarseries, copy all the member definitions and functions, but still get lots of errors.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote last edited by
                  #10

                  Hi,

                  You are meddling with the private APIs so you need to link to the private Qt libraries knowing all the consequence that are explained in the header of these files.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  C 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Hi,

                    You are meddling with the private APIs so you need to link to the private Qt libraries knowing all the consequence that are explained in the header of these files.

                    C Offline
                    C Offline
                    crane_jiang
                    wrote last edited by crane_jiang
                    #11

                    @SGaist
                    yes, the private API is used.
                    the Qhorizontalstackedbarseries class new() QHorizontalStackedBarSeriesPrivate, and then the private new() the HorizontalStackedBarChartItem which has generateLabelText() to show value labels,
                    so I have to rewrite all of them. but always get compile errors.
                    do you have any other simple way suggested to show labels containing set/category index?
                    thank you.

                    1 Reply Last reply
                    0
                    • C crane_jiang

                      @jsulm
                      I make changes in qt lib just to see if it can work, setLabelsFormat() can show customed bar labels with set/category more than just value.
                      but I don't want to use this way seriously.

                      I want to do this by override official QHorizontalStackedBarSeries codes.
                      I find the related codes are under qt-everywhere-src-5.15.12/qtcharts/src/charts/barchart/horizontal/stacked/.
                      (1) horizontalstackedbarchartitem_p.h
                      (2) qhorizontalstackedbarseries.h
                      (3) qhorizontalstackedbarseries_p.h
                      (4) horizontalstackedbarchartitem.cpp
                      (5) qhorizontalstackedbarseries.cpp
                      I want to replace these files with my own ones, myhorizontalstackedbarchartitem_p.h myqhorizontalstackedbarseries.h myqhorizontalstackedbarseries_p.h myhorizontalstackedbarchartitem.cpp myqhorizontalstackedbarseries.cpp, respectively.
                      and then use my customed class myQHorizontalStackedBarSeriesto whose generateLabelsText() support display bar labels to replace official QHorizontalStackedBarSeries.
                      and I do have add "QT += charts-private" in project.pro file.

                      I can't upload my override codes in reply,

                      so I upload it to my space link my qtcharts override codes

                      there are several build errors such as

                      undefined reference to `__imp__ZTVN8QtCharts29myQHorizontalStackedBarSeriesE'
                      undefined reference to `__imp__ZTVN8QtCharts36myQHorizontalStackedBarSeriesPrivateE'
                      

                      I don't know how to fix these errors.
                      thank you

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote last edited by
                      #12

                      @crane_jiang said in how to override qtcharts QBarSeries?:

                      undefined reference to __imp__ZTVN8QtCharts29myQHorizontalStackedBarSeriesE' undefined reference to __imp__ZTVN8QtCharts36myQHorizontalStackedBarSeriesPrivateE'

                      I am not sure as I don't use Qt5, don't have Qt source and don't use Windows or MSVC. But these errors are from MSVC and look like it is failing to find symbols from __declspec(dllimport)/__declspec(dllexport). These come from the Q_CHARTS_PRIVATE_EXPORT/Q_CHARTS_EXPORT in the source files you have copied from Qt. I think e.g. class Q_CHARTS_EXPORT myQHorizontalStackedBarSeries resolves to class __declspec(dllimport) myQHorizontalStackedBarSeries, which is why the symbols start with __imp__. But that is for importing symbols from a DLL, which is what it is in Qt code, but in your code the class you have added does not reside in a DLL.

                      Try removing/commenting out the Q_CHARTS_PRIVATE_EXPORT/Q_CHARTS_EXPORT at least in your myhorizontalstackedbarchartitem_p.h & myqhorizontalstackedbarseries.h to make them regular, non-DLL classes? Does that make it compile, or at least change the "undefined references"? I don't know whether the whole thing will work or whether you will encounter other problems but this may be the resolution for this linker issue.

                      1 Reply Last reply
                      0
                      • C crane_jiang

                        @jsulm
                        yes, I add these 5 myxxx.h/cpp in my project tree, rather than change official source code directly.
                        does it matters?

                        and I have valid company qt-license,
                        how can I connect official support engineer for help?

                        Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote last edited by
                        #13

                        @crane_jiang said in how to override qtcharts QBarSeries?:

                        yes, I add these 5 myxxx.h/cpp in my project tree, rather than change official source code directly.
                        does it matters

                        Again: when you modify the Qt source you have to recompile it. What's so hard to understand here?

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

                        JonBJ 1 Reply Last reply
                        0
                        • Christian EhrlicherC Christian Ehrlicher

                          @crane_jiang said in how to override qtcharts QBarSeries?:

                          yes, I add these 5 myxxx.h/cpp in my project tree, rather than change official source code directly.
                          does it matters

                          Again: when you modify the Qt source you have to recompile it. What's so hard to understand here?

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote last edited by JonB
                          #14

                          @Christian-Ehrlicher
                          As I understand it and the user's attached files, for right or for wrong they are trying to introduce a subclass of QHorizontalStackedBarSeries, and they are doing this in their own program, not in Qt library code. They have simply copied a few files from Qt sources to allow them to make appropriate new code.

                          I may be mistaken --- please feel free to correct me --- but I do not see why that should require alteration or recompilation of existing Qt code. Hence my reply above suggesting that at present they have a problem with compiling the code they copied from when it is to be compiled within a project rather than as a standalone library/DLL, which is how the code they have copied from is written in Qt.

                          I do not disagree that the simplest might be to simply make their changes or additions in the Qt QtCharts source code and recompile. Especially since neither QtCharts nor Qt 5.15 is going to undergo changes. But if they want to try putting the new code in their own project rather than into Qt source with recompile I am currently thinking that is possible, with the modification I suggested earlier. If that does not work then they may have to take the Qt source route.

                          Christian EhrlicherC 1 Reply Last reply
                          0
                          • JonBJ JonB

                            @Christian-Ehrlicher
                            As I understand it and the user's attached files, for right or for wrong they are trying to introduce a subclass of QHorizontalStackedBarSeries, and they are doing this in their own program, not in Qt library code. They have simply copied a few files from Qt sources to allow them to make appropriate new code.

                            I may be mistaken --- please feel free to correct me --- but I do not see why that should require alteration or recompilation of existing Qt code. Hence my reply above suggesting that at present they have a problem with compiling the code they copied from when it is to be compiled within a project rather than as a standalone library/DLL, which is how the code they have copied from is written in Qt.

                            I do not disagree that the simplest might be to simply make their changes or additions in the Qt QtCharts source code and recompile. Especially since neither QtCharts nor Qt 5.15 is going to undergo changes. But if they want to try putting the new code in their own project rather than into Qt source with recompile I am currently thinking that is possible, with the modification I suggested earlier. If that does not work then they may have to take the Qt source route.

                            Christian EhrlicherC Offline
                            Christian EhrlicherC Offline
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote last edited by
                            #15

                            @JonB said in how to override qtcharts QBarSeries?:

                            . They have simply copied a few files from Qt sources to allow them to make appropriate new code.

                            And how should this work? Apart from the name clash the export macros are wrong.

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

                            JonBJ 1 Reply Last reply
                            0
                            • Christian EhrlicherC Christian Ehrlicher

                              @JonB said in how to override qtcharts QBarSeries?:

                              . They have simply copied a few files from Qt sources to allow them to make appropriate new code.

                              And how should this work? Apart from the name clash the export macros are wrong.

                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote last edited by
                              #16

                              @Christian-Ehrlicher said in how to override qtcharts QBarSeries?:

                              the export macros are wrong.

                              Which is exactly what I wrote above in https://forum.qt.io/post/829183. I don't know about "name clash".

                              Anyway if you are sure this cannot be done by adding a new subclass in own code then I am sure you will be right and the OP would be best just changing the existing Qt source.

                              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