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. The same code works under Windows and fails under GNU/Linux
Forum Updated to NodeBB v4.3 + New Features

The same code works under Windows and fails under GNU/Linux

Scheduled Pinned Locked Moved General and Desktop
26 Posts 5 Posters 10.7k 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.
  • V Offline
    V Offline
    vishwajeet
    wrote on last edited by
    #13

    Good discussion, coming back to main question here.

    which code is getting executed here on Linux could u check that thru debug statement or some other way?

    I mean is it

    @ MyApp app(argc,argv);
    return app.exec(); // event loop
    @

    OR

    @
    if (argc == 3) run(argv[1],argv[2]);
    @

    And how it is different from Windows execution?

    Problem seems simple here i guess, its just you have to check the difference between win and Linux in terms of main() code execution, max u might have to go 1 layer down but that should resolve ur problem.

    Born To Code !!!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #14

      Show us the implementation of your MyApp constructor, please.

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

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

        [quote author="vishwajeet" date="1298555161"]
        Problem seems simple here i guess, its just you have to check the difference between win and Linux in terms of main() code execution, max u might have to go 1 layer down but that should resolve ur problem. [/quote]

        [Highlighting by me]

        Can you please use correct english in your writings. It's hard to read these non obvious abbreviations, especially for non-native speakers. This is neither Twitter nor SMS, we do have far more than 140 available :-) so no need to confuse people.

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

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jerome.bouat
          wrote on last edited by
          #16

          Now the MyApp class has the below declaration :
          @class MyApp : public QApplication
          {
          private:

          Q_OBJECT

          public:
          bool tested;
          QString program;
          streambuf *coutbuf;
          virtual ~MyApp();
          MyApp(int &,char **);
          };@

          And below is its definition :
          @MyApp::MyApp(int &argc,char **argv) : QApplication(argc,argv),program(argv[0]),coutbuf(cout.rdbuf()),tested(false)

          {

          MainWindow *mainWindow = new MainWindow(argc,argv);

          mainWindow->show();

          }@

          I recompiled all but I still get the same issue.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #17

            It's common to instantiate your UI class in the main function after the QApplication (-derived) object has been created.

            I have not tested if that is the cause of your problem, but at least it's common coding style in Qt world.

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

            1 Reply Last reply
            0
            • V Offline
              V Offline
              vishwajeet
              wrote on last edited by
              #18

              Ohhhh i apologies for too many abbreviations in my writing.
              [quote author="Volker" date="1298556541"][quote author="vishwajeet" date="1298555161"]
              Problem seems simple here i guess, its just you have to check the difference between win and Linux in terms of main() code execution, max u might have to go 1 layer down but that should resolve ur problem. [/quote]

              [Highlighting by me]

              Can you please use correct english in your writings. It's hard to read these non obvious abbreviations, especially for non-native speakers. This is neither Twitter nor SMS, we do have far more than 140 available :-) so no need to confuse people.
              [/quote]

              To jerome.bouat

              Could you please check if @MyApp app(argc,argv);
              return app.exec(); // event loop@ is getting executed in case of windows and Linux ?

              Born To Code !!!

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jerome.bouat
                wrote on last edited by
                #19

                The below code fragment is being executed
                on Windows (because the application works properly)
                and Linux (because I don't get the error if I comment it) :
                @MyApp app(argc,argv);
                return app.exec(); // event loop@

                I moved the GUI initialization in a separate method (createWindow) :
                @class MyApp : public QApplication

                {

                private:

                Q_OBJECT

                public:

                bool tested;

                QString program;

                streambuf *coutbuf;

                virtual ~MyApp();

                // empty, just call super class constructor
                // and initialize object attributes

                MyApp(int &,char **);

                void createWindow(int &,char **);

                };@

                Into this new method, I don't get the error message
                if I comment the "show()" call
                @void MyApp::createWindow(int &argc,char **argv)

                {

                MainWindow *mainWindow = new MainWindow(argc,argv);

                mainWindow->show(); // no error if commented

                }@

                Thus, the issue seems to be located into the super-super class method QWidget::show().

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #20

                  No way to analyze this here. Can you please:

                  • make a small test case
                  • put it into a complete project
                  • make sure it compiles, runs and shows the error
                  • put the sources (and only these) into a ZIP
                  • put the ZIP on dropbox, pastebin or make it available somewhere else
                  • post the link here

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

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jerome.bouat
                    wrote on last edited by
                    #21

                    It seems to be an OpenGL issue but the error message I reported is far from that.

                    I'm investigating.

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      jerome.bouat
                      wrote on last edited by
                      #22

                      Just a Qt newbie question : I assume that all calls like below should be located into header files only and not cpp files :
                      @QObject::connect(scrollBar, SIGNAL(valueChanged(int)), label, SLOT(setNum(int)));@
                      ?

                      Or could we possibly use this call into cpp files by including the right Qt file ?

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #23

                        It's an ordinary call of a static method. You put it into regular method bodies. That happens mostly in the .cpp files, but can be put into headers too.

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

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          andre
                          wrote on last edited by
                          #24

                          What's more, in most cases the right file is already included when you call this: the header of either of the objects you want to connect. If you find that you can not use the connect call: it is to be found in the QObject header.

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            jerome.bouat
                            wrote on last edited by
                            #25

                            I assume the "emit" keyword can be used in cpp files ?

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              andre
                              wrote on last edited by
                              #26

                              Perhaps you should work through one of the basic Qt tutorials. This is all explained very well in the documentation, there is even a section called "Signals & Slots" that explains in detail how this all works.

                              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