Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Wiki Discussion
  4. Getting started example is buggy

Getting started example is buggy

Scheduled Pinned Locked Moved Wiki Discussion
10 Posts 6 Posters 8.7k 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.
  • G Offline
    G Offline
    goetz
    wrote on last edited by
    #1

    The second example in the "Getting Started Programming with Qt":http://doc.qt.nokia.com/4.7/gettingstartedqt.html guide is buggy.

    The wrong code is:

    @
    #include <QtGui>

    int main(int argv, char **args)
    {
    QApplication app(argv, args);

    QTextEdit textEdit;
    QPushButton quitButton("Quit");
    
    QObject::connect(&quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
    
    QVBoxLayout layout;
    layout.addWidget(&textEdit);
    layout.addWidget(&quitButton);
    
    QWidget window;
    window.setLayout(&layout);
    
    window.show();
    
    return app.exec();
    

    }
    @

    The program segfaults on quitting. I suspect, that it is due to double deconstruction of textEdit and quitButton on program exit. They are constructed on the stack, and therefore destructed because they're going out of scope. Unfortunately they are deconstructed a second time, when window is destroyed, due to the fact that they are reparented to window, as soon as the layout is set.

    I've reworked it, so that it works now and is more "Qt'ish", using pointers for child widgets:

    @
    #include <QtGui>

    int main(int argv, char **args)
    {
    QApplication app(argv, args);

    QWidget window;
    
    QTextEdit *textEdit = new QTextEdit(&window);
    QPushButton *quitButton = new QPushButton("Beenden");
    
    QObject::connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
    
    QVBoxLayout layout;
    layout.addWidget(textEdit);
    layout.addWidget(quitButton);
    
    window.setLayout(&layout);
    
    window.show();
    
    return app.exec();
    

    }
    @

    Should we adapt the translated versions here in the wiki?

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

    1 Reply Last reply
    0
    • P Offline
      P Offline
      parancibia
      wrote on last edited by
      #2

      I fix the "spanish version":http://developer.qt.nokia.com/wiki/GettingStartedQt_Spanish

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xsacha
        wrote on last edited by
        #3

        Just a small note since I guess everyone will be fixing up their wikis:
        paulo: You seem to have translated the text on the QPushButton in the wiki code to "Salir". Yet the following screenshots and tutorial refer to it as "Quit".
        Further on in the code of the tutorial, the QPushButton instead has the text "Quit" as well.

        • Sacha
        1 Reply Last reply
        0
        • K Offline
          K Offline
          kamalakshantv
          wrote on last edited by
          #4

          [quote author="xsacha" date="1291774911"]Just a small note since I guess everyone will be fixing up their wikis:
          paulo: You seem to have translated the text on the QPushButton in the wiki code to "Salir". Yet the following screenshots and tutorial refer to it as "Quit".
          Further on in the code of the tutorial, the QPushButton instead has the text "Quit" as well.[/quote]

          That might be due to just translating the text and not the example applications. Might have used the same screen shots originally available.

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xsacha
            wrote on last edited by
            #5

            I know, don't know if screenshots are intentional.
            However, the code has translated text in the first instance "Salir", but not the second instance "Quit". This cannot be intentional.

            And what about references to the text?

            • Sacha
            1 Reply Last reply
            0
            • D Offline
              D Offline
              donallen
              wrote on last edited by
              #6

              @Volker:

              You posted your message year and a half ago, and the Getting Started manual still has this bug, to give others like me a chance to waste their time on it. Good work!

              /Don Allen

              1 Reply Last reply
              0
              • K Offline
                K Offline
                koahnig
                wrote on last edited by
                #7

                [quote author="donallen" date="1341778891"]@Volker:

                You posted your message year and a half ago, and the Getting Started manual still has this bug, to give others like me a chance to waste their time on it. Good work!

                /Don Allen[/quote]
                In the recent "version 4.8":http://qt-project.org/doc/qt-4.8/gettingstartedqt.html the doc bug is fixed. It even has Volker's note at the bottom.

                Which version of the documentation did you use?

                [edit, typo corrected]

                Vote the answer(s) that helped you to solve your issue(s)

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  donallen
                  wrote on last edited by
                  #8

                  If you start at qt.nokia.com, which you find if you google for 'qt'. If you click 'Learn Qt', then 'Getting Started Guides', and then 'Getting Started Programming with Qt', you end up at

                  http://doc.qt.nokia.com/4.7/gettingstartedqt.html

                  which still has the bug.

                  So apparently the error was fixed in the 4.8 documentation, but the website takes you by default to the 4.7 version. Perhaps this isn't Volker's fault and if not, I apologize to him for my snotty message. But this is somebody's screwup, because the path I followed is the path a Qt novice, which I am, will follow, starting with the qt home page. If you follow your nose, starting with the qt home page, you end up at documentation for an old release.

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    koahnig
                    wrote on last edited by
                    #9

                    IMO it is certainly not Volker's fault. You ran into a serious of mischief. At the devnet version of doc 4.7 "http://qt-project.org/doc/qt-4.7/gettingstartedqt.html":http://qt-project.org/doc/qt-4.7/gettingstartedqt.html has Volker's note at the bottom. I believe the version you have been trapped is has been migrated to devnet. If you just change the version number on your link it will automatically go to the devnet version.

                    Finally, the problem is Google's memory and probably the interest in Qt's documentation. It may take some time to change priorities there. I have noted also in the past that Google points to the older version 4.7 and reported it. Most likely nobody from Qt devnet can do anything about Google's list.

                    Vote the answer(s) that helped you to solve your issue(s)

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      koahnig
                      wrote on last edited by
                      #10

                      I have filed a "bug report on JIRA.":https://bugreports.qt-project.org/browse/QTWEBSITE-455 Let's see, if someone of the Trolls may do anything about it.

                      Vote the answer(s) that helped you to solve your issue(s)

                      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