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. [SOLVED]Qvector Problem instansiate Thanks ALL
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Qvector Problem instansiate Thanks ALL

Scheduled Pinned Locked Moved General and Desktop
31 Posts 5 Posters 12.5k 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.
  • P Offline
    P Offline
    p-himik
    wrote on 21 Nov 2011, 11:11 last edited by
    #20

    toho71 either you have to read more about C++ or you did horrible typo. Here it is:
    @myClass::~myClass()
    {
    delete this;
    }@

    1 Reply Last reply
    0
    • T Offline
      T Offline
      toho71
      wrote on 21 Nov 2011, 11:30 last edited by
      #21

      copy and paste is the to magic words
      Ok now it works again.

      I have to look in my header prj to and see if this is the magic case.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        toho71
        wrote on 21 Nov 2011, 11:59 last edited by
        #22

        in my testcase i do like this in my constructor

        @GlobalParams::GlobalParams()
        {
        testRunning(false);

        qDebug() << presetVector.isEmpty();
        qDebug() << presetVector.size() << " vectorsize  and kapacitet =" << presetVector.capacity();
        
        //Create a tempobject for test
        ClPresetLoadsTestValues p(10,10,10);
        
        qDebug() << "create  object ";
        
        presetVector.append(p);
        qDebug() << "appendat obj";
        qDebug() << presetVector.size() << " vectorsize  and kapacitet =" << presetVector.capacity();
        

        }@

        and I got this text in my consol

        true
        0 vectorsize and kapacitet = 0
        create ClPresetLoadsTestValues
        create object
        delete ClPresetLoadsTestValues
        appendat obj
        1 vectorsize and kapacitet = 1
        delete ClPresetLoadsTestValues

        And later when I try to add a ClPresetLoadsTestValues my program crashes and NO i don't delete the object.

        here is my object

        @@ClPresetLoadsTestValues::ClPresetLoadsTestValues()
        {
        qDebug() << "create ClPresetLoadsTestValues";
        }

        ClPresetLoadsTestValues::ClPresetLoadsTestValues(int k, int m, int s)
        {
        this->kw = k;
        this->min = m;
        this->sec = s;
        qDebug() << "create ClPresetLoadsTestValues";
        }

        ClPresetLoadsTestValues::~ClPresetLoadsTestValues()
        {
        qDebug() << "delete ClPresetLoadsTestValues";
        }

        //set and getters
        @

        and my func to add the obj

        @void GlobalParams::addValuesToLoadsTestTemp(int kw, int min, int sec)
        {
        ClPresetLoadsTestValues p(kw,min,sec);

        qDebug() << "try to append";
         qDebug() << this->presetVector.size() << " vektorstorlek"; //IT crashes here
        
        if (this->presetVector.isEmpty())
            qDebug() << "Empty";
         else
            qDebug() << "SIZE " << presetVector.size() ;
        
        presetVector.append(p);
         qDebug() << "appendad";
        

        }

        @

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p-himik
          wrote on 21 Nov 2011, 12:05 last edited by
          #23

          Can you make another tarball?

          1 Reply Last reply
          0
          • T Offline
            T Offline
            toho71
            wrote on 21 Nov 2011, 12:07 last edited by
            #24

            it gonna be big with many files but maybe only the files in the spec region and it will not compile.
            I'll try

            1 Reply Last reply
            0
            • P Offline
              P Offline
              p-himik
              wrote on 21 Nov 2011, 12:10 last edited by
              #25

              You should provide only source files. Do not include object files (and autogenerated moc_, ui_, qrc_*) in the tarball.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                toho71
                wrote on 21 Nov 2011, 12:14 last edited by
                #26

                Here it is

                the two files with this problem
                "myFiles":http://rghost.net/31396481

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on 21 Nov 2011, 13:05 last edited by
                  #27

                  Please provide a

                  • complete
                  • compilable
                  • minimal

                  test case.

                  leave out

                  • intermediate object file (*.o)
                  • autogenerated stuff from moc and uic (moc_.cpp, ui_.h)
                  • Qt Creator user data (*.pro.user)
                  • the final executable

                  You're more likely to get an answer if the fellows trying to help here in the forums do not need to guess how to set up a correct test case and a project file.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    toho71
                    wrote on 21 Nov 2011, 13:39 last edited by
                    #28

                    Here is a full tested version with compiling.

                    I uploaded a small ex earlier
                    "MyApp":http://rghost.net/31409351

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      toho71
                      wrote on 21 Nov 2011, 15:22 last edited by
                      #29

                      it works very well to append objects when I instantiates the object globalParam but later when I try to append some new objects later in the program it seems like the vector isn't there.

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on 27 Nov 2011, 21:39 last edited by
                        #30

                        Unfortunately I can spend some time on it right now, but the archive is no longer available. Do you mind uploading it again, please?

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          toho71
                          wrote on 28 Nov 2011, 10:17 last edited by
                          #31

                          Volker
                          I got it solved and it had a Nullpointer in another place so this worked fine but some dependent functions made some errors to this.
                          //T

                          1 Reply Last reply
                          0

                          29/31

                          21 Nov 2011, 15:22

                          • Login

                          • Login or register to search.
                          29 out of 31
                          • First post
                            29/31
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved