Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved How to check an existance of a chart?

    General and Desktop
    3
    5
    109
    Loading More Posts
    • 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.
    • F
      firsnur96 last edited by

      How can i check the existance of chart_olstr[0] for removing the series.
      Because if chart_olstr[0] is not exist my app crash

            ```
            chart_olstr[0]->removeSeries(seri[i]);
            chart_olstr[0]->legend()->hide();
            chart_olstr[0]->update();
            seri[i]->clear();
      
      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @firsnur96 last edited by JonB

        @firsnur96 said in How to check an existance of a chart?:

        Because if chart_olstr[0] is not exist my app crash

        Is chart_olstr an array or list or whatever? So check its length/count or whether it is empty before attempting to address element #0 in it....

        F 1 Reply Last reply Reply Quote 1
        • F
          firsnur96 @JonB last edited by

          @JonB yes it is an array.
          I cannot found any function like isEmpy, how should i check its lenght

          JonB Pl45m4 2 Replies Last reply Reply Quote 0
          • JonB
            JonB @firsnur96 last edited by JonB

            @firsnur96
            Look at the documentation for whatever actual type you mean by "array".

            If it is a C-array, it won't have any varying length/count. But then you know its size/what elements you put in, or you are maintaining your own count variable.

            1 Reply Last reply Reply Quote 1
            • Pl45m4
              Pl45m4 @firsnur96 last edited by

              @firsnur96

              What kind of array? QVector? QList?
              What about chart_olstr.size()?

              Or just check element 0:
              chart_olstr[0] != nullptr


              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 Reply Quote 0
              • First post
                Last post