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.8k 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 last edited by
    #14

    I think that any file sharing hosting will be suitable. For example try http://rghost.net/

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #15

      look for a file hoster (e.g. gitorious.org, but you need a logon) or any other

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        toho71
        wrote on last edited by
        #16

        I have discovered a problem know that is a little confusing.

        When I try to append a Object or a struct thats not in the class where the vector is the program crashes but when I put a struct inside the class and append this to the vector it works fine

        1 Reply Last reply
        0
        • T Offline
          T Offline
          toho71
          wrote on last edited by
          #17

          Here is not the TAR file to test

          1 Reply Last reply
          0
          • P Offline
            P Offline
            p-himik
            wrote on last edited by
            #18

            Your code works without any crashes. I didn't do any changes though.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              toho71
              wrote on last edited by
              #19

              Try again with this code
              I had comment the problem spots in the last code.
              The new one is here
              "Vectorproblems":http://rghost.net/31386231

              pls

              1 Reply Last reply
              0
              • P Offline
                P Offline
                p-himik
                wrote on 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 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 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 last edited by
                      #23

                      Can you make another tarball?

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        toho71
                        wrote on 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 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 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 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 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 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 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 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

                                      • Login

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