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. Save object to a file

Save object to a file

Scheduled Pinned Locked Moved General and Desktop
37 Posts 2 Posters 13.1k 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.
  • D Offline
    D Offline
    Dmon
    wrote on 13 Aug 2013, 19:44 last edited by
    #9

    I thought that FilmWriter would need to inherit Film in order to create an object of type Film. Film inheriting QWidget is a mistake as it is left over from the question which was one class called film inheriting QWidget which I have to break up into 3 classes and then add functionality. Also the UI file was created automatically for me with Qt creator. I will look up some info on interfaces. So the question is to have the saveFilm function in the filmWriter class, how do I get it to work like that rather than making saveFilm a member of FilmInput and removing the FilmWriter class?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 Aug 2013, 20:16 last edited by
      #10

      No it doesn't, as long as it knows how to use Film.

      For the rest it's essentially doc reading

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        Dmon
        wrote on 13 Aug 2013, 20:26 last edited by
        #11

        if I take out #include "Film.h" in FilmWriter there is a problem with the FilmWriter class, if I then take out : public Film there is a problem with the func saveFilm because it's parameter is of type Film. So how do I make it know how to use Film?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 13 Aug 2013, 20:32 last edited by
          #12

          This is C/C++ basic knowledge. Without the header file how would your class know anything about Film ?

          What problem would it be ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dmon
            wrote on 13 Aug 2013, 20:39 last edited by
            #13

            well it wouldn't know about Film without the header file. Are you saying that it doesn't need to be a child of Film but just include the header?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 13 Aug 2013, 21:04 last edited by
              #14

              Yes, it's exactly what I'm saying

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Dmon
                wrote on 13 Aug 2013, 21:14 last edited by
                #15

                Ok great. But now after the changes I am still getting the same error :-?
                :: error: collect2: ld returned 1 exit status

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 13 Aug 2013, 21:18 last edited by
                  #16

                  If you are talking about the saveFilm problem and the message didn't changed, then saveFilm is still not a member of FilmInput.

                  Isn't it a member of FilmWriter ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    Dmon
                    wrote on 13 Aug 2013, 21:24 last edited by
                    #17

                    Yes and I don't want it to be a member of FilmInput, I want it to be member of FilmWriter only and somehow (I don't know how) be called in FilmInput. I thought if I included the FilmWriter header it would work, but obviously I must do something else.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 13 Aug 2013, 21:25 last edited by
                      #18

                      FilmWriter is a class, how do you call a function from a class ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        Dmon
                        wrote on 13 Aug 2013, 21:36 last edited by
                        #19

                        You create an object and call the function with the object. That's it! Ok so now you have helped me to get rid of that error, thanks a lot. Another question, when I click on the save film button which invokes saveFilm the program crashes, should I start a new thread because this is a new question or can you still help me on this one?

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 13 Aug 2013, 21:49 last edited by
                          #20

                          Run your application through the debugger, it will tell you where the crash occurs

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            Dmon
                            wrote on 14 Aug 2013, 06:56 last edited by
                            #21

                            I got this: The inferior stopped because it received a signal from the operating system
                            signal name: SIGSEGV
                            Signal meaning: Segmentation fault
                            then it is pointing to line 2185 in qglobal.h
                            inline QFlags operator&(Enum f) const { QFlags g; g.i = i & f; return g; }

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 14 Aug 2013, 07:06 last edited by
                              #22

                              What does the stack trace look like ?
                              The lines under qglobal.h ?

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • D Offline
                                D Offline
                                Dmon
                                wrote on 14 Aug 2013, 07:19 last edited by
                                #23

                                I have a print screen, how do I post a pic on here?

                                1 Reply Last reply
                                0
                                • S Offline
                                  S Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on 14 Aug 2013, 07:30 last edited by
                                  #24

                                  You have to use a picture hosting service or a public dropbox folder etc...

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • D Offline
                                    D Offline
                                    Dmon
                                    wrote on 14 Aug 2013, 07:43 last edited by
                                    #25

                                    https://www.dropbox.com/s/oal5r9sjtsmy42l/Qt stack.jpg

                                    1 Reply Last reply
                                    0
                                    • D Offline
                                      D Offline
                                      Dmon
                                      wrote on 14 Aug 2013, 07:44 last edited by
                                      #26

                                      https://www.dropbox.com/s/mosnz8o23elipn5/Qtstack.jpg

                                      doesn't work with a space in the name

                                      1 Reply Last reply
                                      0
                                      • S Offline
                                        S Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on 14 Aug 2013, 08:05 last edited by
                                        #27

                                        Looks strange... Just to be on the safe side, delete the build directory completely and re-run your application.

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        0
                                        • D Offline
                                          D Offline
                                          Dmon
                                          wrote on 14 Aug 2013, 08:19 last edited by
                                          #28

                                          ok now it doesn't run again with a bunch of errors:

                                          Running build steps for project Ass1Q1...
                                          Configuration unchanged, skipping qmake step.
                                          Starting: "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" -w
                                          mingw32-make: Entering directory C:/Unisa/COS3711/assignments/Ass1Q1-build-desktop' C:/Qt/2010.04/mingw/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory C:/Unisa/COS3711/assignments/Ass1Q1-build-desktop'
                                          g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"........\Qt\2010.04\qt\include\QtCore" -I"........\Qt\2010.04\qt\include\QtGui" -I"........\Qt\2010.04\qt\include" -I"........\Qt\2010.04\qt\include\ActiveQt" -I"debug" -I"." -I"..\Ass1Q1" -I"." -I"........\Qt\2010.04\qt\mkspecs\win32-g++" -o debug\FilmWriter.o ..\Ass1Q1\FilmWriter.cpp
                                          ..\Ass1Q1\FilmWriter.cpp: In member function 'void FilmWriter::saveFilm(Film&)':
                                          ..\Ass1Q1\FilmWriter.cpp:10: error: no matching function for call to 'QFileDialog::getSaveFileName(FilmWriter* const, const char [10])'
                                          ........\Qt\2010.04\qt\include\QtGui/../../src/gui/dialogs/qfiledialog.h:216: note: candidates are: static QString QFileDialog::getSaveFileName(QWidget*, const QString&, const QString&, const QString&, QString*, QFlagsQFileDialog::Option)
                                          ..\Ass1Q1\FilmWriter.cpp:14: error: no matching function for call to 'QMessageBox::critical(FilmWriter* const, const char [6], const char [20])'
                                          ........\Qt\2010.04\qt\include\QtGui/../../src/gui/dialogs/qmessagebox.h:202: note: candidates are: static QMessageBox::StandardButton QMessageBox::critical(QWidget*, const QString&, const QString&, QFlagsQMessageBox::StandardButton, QMessageBox::StandardButton)
                                          ........\Qt\2010.04\qt\include\QtGui/../../src/gui/dialogs/qmessagebox.h:262: note: static int QMessageBox::critical(QWidget*, const QString&, const QString&, int, int, int)
                                          ........\Qt\2010.04\qt\include\QtGui/../../src/gui/dialogs/qmessagebox.h:265: note: static int QMessageBox::critical(QWidget*, const QString&, const QString&, const QString&, const QString&, const QString&, int, int)
                                          ........\Qt\2010.04\qt\include\QtGui/../../src/gui/dialogs/qmessagebox.h:272: note: static int QMessageBox::critical(QWidget*, const QString&, const QString&, QMessageBox::StandardButton, QMessageBox::StandardButton)
                                          mingw32-make[1]: Leaving directory C:/Unisa/COS3711/assignments/Ass1Q1-build-desktop' mingw32-make: Leaving directory C:/Unisa/COS3711/assignments/Ass1Q1-build-desktop'
                                          mingw32-make[1]: *** [debug/FilmWriter.o] Error 1
                                          mingw32-make: *** [debug] Error 2
                                          The process "C:/Qt/2010.04/mingw/bin/mingw32-make.exe" exited with code %2.
                                          Error while building project Ass1Q1 (target: Desktop)
                                          When executing build step 'Make'

                                          1 Reply Last reply
                                          0

                                          18/37

                                          13 Aug 2013, 21:25

                                          • Login

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