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. 'setAxisY' is deprecated in Qt Charts
Forum Updated to NodeBB v4.3 + New Features

'setAxisY' is deprecated in Qt Charts

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 5 Posters 7.6k 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.
  • S Offline
    S Offline
    saber
    wrote on last edited by saber
    #1

    i want to remove the warnings

    mChart->setAxisY (mAxisY, mSeriesList.at(i));
    

    what will be the right way to fix this waring?

    i did the fix for other and are those correct?

        mChart->axes(Qt::Horizontal).back()->setRange(0,60);
    //    mChart->axisX()->setRange(0, 60);
        mChart->axes(Qt::Horizontal).back()->setReverse(true);
    //    mChart->axisX()->setReverse(true);
    
    jsulmJ 1 Reply Last reply
    0
    • S saber

      i want to remove the warnings

      mChart->setAxisY (mAxisY, mSeriesList.at(i));
      

      what will be the right way to fix this waring?

      i did the fix for other and are those correct?

          mChart->axes(Qt::Horizontal).back()->setRange(0,60);
      //    mChart->axisX()->setRange(0, 60);
          mChart->axes(Qt::Horizontal).back()->setReverse(true);
      //    mChart->axisX()->setReverse(true);
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @saber What warning exactly do you get? There is no mention of https://doc.qt.io/qt-5/qchart.html#setAxisX being deprecated. In general the correct solution to get rid of deprecated methods is to use the new ones.

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

      S 1 Reply Last reply
      1
      • jsulmJ jsulm

        @saber What warning exactly do you get? There is no mention of https://doc.qt.io/qt-5/qchart.html#setAxisX being deprecated. In general the correct solution to get rid of deprecated methods is to use the new ones.

        S Offline
        S Offline
        saber
        wrote on last edited by saber
        #3

        @jsulm
        qt 5.12 is givinf that

        /home/shaber/Desktop/apps/dashboard/history_chart.cpp:22: warning: ‘void QtCharts::QChart::setAxisY(QtCharts::QAbstractAxis*, QtCharts::QAbstractSeries*)’ is deprecated [-Wdeprecated-declarations]
                     mChart->setAxisY(mAxisY, mSeriesList.at(i));
                                                               ^
        
        

        i found this stack orevflow

        jsulmJ 1 Reply Last reply
        0
        • S saber

          @jsulm
          qt 5.12 is givinf that

          /home/shaber/Desktop/apps/dashboard/history_chart.cpp:22: warning: ‘void QtCharts::QChart::setAxisY(QtCharts::QAbstractAxis*, QtCharts::QAbstractSeries*)’ is deprecated [-Wdeprecated-declarations]
                       mChart->setAxisY(mAxisY, mSeriesList.at(i));
                                                                 ^
          
          

          i found this stack orevflow

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

          @saber Interesting. These methods are really set as depreceted (https://code.woboq.org/qt5/qtcharts/src/charts/qchart.h.html).
          But in the documentation there is no information about it. I never used Qt Charts, so don't know what is the replacement.
          Maybe somebody else knows.
          You could alsy file a bug for the documentation to add missing information.

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

          S 1 Reply Last reply
          1
          • jsulmJ jsulm

            @saber Interesting. These methods are really set as depreceted (https://code.woboq.org/qt5/qtcharts/src/charts/qchart.h.html).
            But in the documentation there is no information about it. I never used Qt Charts, so don't know what is the replacement.
            Maybe somebody else knows.
            You could alsy file a bug for the documentation to add missing information.

            S Offline
            S Offline
            saber
            wrote on last edited by
            #5

            @jsulm
            that will be good idea where i can do that?

            jsulmJ 1 Reply Last reply
            0
            • S saber

              @jsulm
              that will be good idea where i can do that?

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

              @saber said in 'setAxisY' is deprecated:

              that will be good idea where i can do that?

              Here: https://bugreports.qt.io/secure/Dashboard.jspa

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

              S 1 Reply Last reply
              0
              • jsulmJ jsulm

                @saber said in 'setAxisY' is deprecated:

                that will be good idea where i can do that?

                Here: https://bugreports.qt.io/secure/Dashboard.jspa

                S Offline
                S Offline
                saber
                wrote on last edited by
                #7

                @jsulm

                bug repoting is too complicated for me. i am not doing it

                1 Reply Last reply
                -1
                • S Offline
                  S Offline
                  saber
                  wrote on last edited by
                  #8

                  solution

                  mChart->axes(Qt::Vertical, mSeriesList.at(i)).append(mAxisY);
                  
                  1 Reply Last reply
                  1
                  • M Offline
                    M Offline
                    mnelson
                    wrote on last edited by
                    #9

                    I found the following to be an acceptable replacement:

                    m_chart->addAxis(m_xAxis, Qt::AlignBottom);
                    m_chart->addAxis(m_yAxis, Qt::AlignLeft);
                    
                    1 Reply Last reply
                    1
                    • L Offline
                      L Offline
                      lshiren
                      wrote on last edited by
                      #10

                      In fact, the resolution is described here:
                      https://doc-snapshots.qt.io/qt5-5.12/qchart-obsolete.html

                      This function is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

                      Use addAxis() instead.

                      1 Reply Last reply
                      1
                      • M Offline
                        M Offline
                        MauroB
                        wrote on last edited by
                        #11

                        just an additional comment, addAxis adds the axis to the chart, but then you need to attach the axis to your series using attachAxis. In your case you can substitute this:

                        mChart->setAxisY (mAxisY, mSeriesList.at(i));
                        

                        with:

                        mChart->addAxis(mAxisY, Qt::AlignLeft);
                        mSeriesList.at(i)->attachAxis(mAxisY);    --> you can also put this in a loop
                        
                        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