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. my program has unexpectedly finished in QCustomPlot set name
Qt 6.11 is out! See what's new in the release blog

my program has unexpectedly finished in QCustomPlot set name

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 5 Posters 1.4k 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.
  • F Offline
    F Offline
    firsnur96
    wrote on last edited by
    #1

    Hi everyone. I have a struct which i show you in below.

    typedef struct list_item {
        char isim[24];
        int idx;
        int chart_no;
        int tip; // 1: float, 2: int, 3: char, 4 string
    //    QLineSeries seri;
        int graph_no;
        QCPGraph *gr;
    }list_item;
    

    I want to achive QCustomPlot graphs and set a name to them. I've written this code for it

    zs_gps[idx_gps].gr->setName(zs_gps[idx_gps].isim);
    

    When i run it, my program has unexpectedly finished. When i debug i saw that in this sentence it crashed.

    void QCPAbstractPlottable::setName(const QString &name)
    {
      mName = name;         ///in here it crashed
    }
    

    What am i doing wrong?

    jsulmJ 1 Reply Last reply
    0
    • F firsnur96

      Hi everyone. I have a struct which i show you in below.

      typedef struct list_item {
          char isim[24];
          int idx;
          int chart_no;
          int tip; // 1: float, 2: int, 3: char, 4 string
      //    QLineSeries seri;
          int graph_no;
          QCPGraph *gr;
      }list_item;
      

      I want to achive QCustomPlot graphs and set a name to them. I've written this code for it

      zs_gps[idx_gps].gr->setName(zs_gps[idx_gps].isim);
      

      When i run it, my program has unexpectedly finished. When i debug i saw that in this sentence it crashed.

      void QCPAbstractPlottable::setName(const QString &name)
      {
        mName = name;         ///in here it crashed
      }
      

      What am i doing wrong?

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

      @firsnur96 Is gr pointer properly initialized (pointing to a valid QCPGraph instance)?

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

      F 1 Reply Last reply
      3
      • jsulmJ jsulm

        @firsnur96 Is gr pointer properly initialized (pointing to a valid QCPGraph instance)?

        F Offline
        F Offline
        firsnur96
        wrote on last edited by
        #3

        @jsulm I thought that, in this sentence i initialized

        zs_gps[idx_gps].gr->setName(zs_gps[idx_gps].isim);
        
        jsulmJ 1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @firsnur96 said in my program has unexpectedly finished in QCustomPlot set name:

          zs_gps[idx_gps].gr

          Where do you initialize gr ?

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

          F 1 Reply Last reply
          0
          • F firsnur96

            @jsulm I thought that, in this sentence i initialized

            zs_gps[idx_gps].gr->setName(zs_gps[idx_gps].isim);
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @firsnur96 said in my program has unexpectedly finished in QCustomPlot set name:

            in this sentence i initialized

            I don't see any initialisation here...

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

            1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @firsnur96 said in my program has unexpectedly finished in QCustomPlot set name:

              zs_gps[idx_gps].gr

              Where do you initialize gr ?

              F Offline
              F Offline
              firsnur96
              wrote on last edited by
              #6

              @Christian-Ehrlicher

              I know that, when i wrote this is already initialize.
              I use the same structure in qt charts and it runs.

              zs_gps[idx_gps].gr 
              

              like

              zs_gps[idx_gps].seri.setName(zs_gps[idx_gps].isim);
              

              And i dont really understand , what should i initialize.

              jsulmJ 1 Reply Last reply
              0
              • F firsnur96

                @Christian-Ehrlicher

                I know that, when i wrote this is already initialize.
                I use the same structure in qt charts and it runs.

                zs_gps[idx_gps].gr 
                

                like

                zs_gps[idx_gps].seri.setName(zs_gps[idx_gps].isim);
                

                And i dont really understand , what should i initialize.

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

                @firsnur96 said in my program has unexpectedly finished in QCustomPlot set name:

                And i dont really understand , what should i initialize.

                gr
                You should have this somewhere:

                gr = new QCPGraph();
                

                So, do you have it somewhere?

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

                F 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @firsnur96 said in my program has unexpectedly finished in QCustomPlot set name:

                  And i dont really understand , what should i initialize.

                  gr
                  You should have this somewhere:

                  gr = new QCPGraph();
                  

                  So, do you have it somewhere?

                  F Offline
                  F Offline
                  firsnur96
                  wrote on last edited by
                  #8

                  @jsulm I wrote it in my cpp file, it gives an error.
                  use of undeclared identifier gr

                  jsulmJ 1 Reply Last reply
                  0
                  • F firsnur96

                    @jsulm I wrote it in my cpp file, it gives an error.
                    use of undeclared identifier gr

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

                    @firsnur96 Please show the code. Also, gr is part of list_item struct, you can't use it just like "gr". The code I posted before is just to illustrate what you need to do, not the exact code...

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

                    F 1 Reply Last reply
                    3
                    • jsulmJ jsulm

                      @firsnur96 Please show the code. Also, gr is part of list_item struct, you can't use it just like "gr". The code I posted before is just to illustrate what you need to do, not the exact code...

                      F Offline
                      F Offline
                      firsnur96
                      wrote on last edited by
                      #10

                      @jsulm

                      zs_gps[idx_gps].gr = new QCPGraph;

                      JonBJ jsulmJ 2 Replies Last reply
                      0
                      • F firsnur96

                        @jsulm

                        zs_gps[idx_gps].gr = new QCPGraph;

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #11

                        @firsnur96

                        • Show you actual relevant code, rather than isolated lines at a time.
                        • If you get a compilation error, copy & paste the actual message here. Assuming the message includes a line number, tell us which exact line in your code that refers to by checking the line number (not guessing).
                        • If you get a runtime error on zs_gps[idx_gps]... something, use the debugger or a qDebug() statement on the line immediately preceding this to prove what zs_gps[idx_gps] is and the value of zs_gps[idx_gps].gr.
                        1 Reply Last reply
                        5
                        • F firsnur96

                          @jsulm

                          zs_gps[idx_gps].gr = new QCPGraph;

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

                          @firsnur96 said in my program has unexpectedly finished in QCustomPlot set name:

                          zs_gps[idx_gps].gr = new QCPGraph;

                          Is this done before zs_gps[idx_gps].seri.setName(zs_gps[idx_gps].isim);?
                          Instead of wasting time here you could simply debug your app to find out what is happening...

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

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

                            Hi
                            You should give the list_item type
                            a constructor that initializes its members.

                            Having to do it outside is a disaster waiting to happen. (IMHO)

                            typedef struct list_item {
                              char isim[24];
                              int idx;
                              int chart_no;
                              int tip; // 1: float, 2: int, 3: char, 4 string
                              //    QLineSeries seri;
                              int graph_no;
                              QCPGraph* gr;
                              explicit list_item() : gr(new QCPGraph ) {}  /// init
                            } list_item;
                            
                            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