×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Error in QT Documentation

    Hello folks,
    QT assistant provides me with the following bit of code:
    Code:
     QMessageBox msgBox;
     QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
     QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
    
     msgBox.exec();
    
     if (msgBox.clickedButton() == connectButton) {
         // connect
     } else if (msgBox.clickedButton() == abortButton) {
         // abort
     }
    When compiling it with GCCE, I get a compiler error about a explicit typecast being needed.

    The correct (compiling) code looks like this - just look at the casts in the if and ignore the rest (altough sewtting a text title might also pay off):
    Code:
    			QMessageBox msgBox;
    					QPushButton *okButton = msgBox.addButton("Connect", QMessageBox::ActionRole);
    					QPushButton *neverAgainButton = msgBox.addButton("Don't show again",QMessageBox::ActionRole);
    					msgBox.setText("Welcome to level 2! Tap the status bar to pause the game...");
    					msgBox.exec();
    					
    					if (msgBox.clickedButton() == (QAbstractButton*)okButton) 
    					{
    					 // do nothing special
    					} 
    					else if (msgBox.clickedButton() == (QAbstractButton*)neverAgainButton) 
    					{//block forever
    					 prefs.hintsettings.lvlclearedhint=1;
    					}
    PLEASE, someone, forward this to the QT heads.
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  2. #2
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Error in QT Documentation

    Hi Tam,

    I don't know where Quick Time bug reports can be created but for Qt 4.6 you can have a look at http://doc.trolltech.com/4.6/bughowto.html
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  3. #3
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Error in QT Documentation

    Code:
    #include <QApplication>
    #include <QMessageBox>
    #include <QPushButton>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QMessageBox msgBox;
        QPushButton *connectButton = msgBox.addButton("Connect", QMessageBox::ActionRole);
        QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);
    
        msgBox.exec();
    
        if (msgBox.clickedButton() == connectButton) {
            qDebug("Connect");
        } else if (msgBox.clickedButton() == abortButton) {
            qDebug("Abort");
        }
    }
    Code:
    $ make
    g++ -c -pipe -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib64/qt4/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -o main.o main.cpp
    g++ -Wl,-O1 -o bugInQt main.o     -lQtGui -lQtCore -lpthread
    http://catb.org/~esr/faqs/smart-questions.html#id382249

  4. #4
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Error in QT Documentation

    MAAAN!

    I know it compiles for Windows. But it doesnt compile when using GCCE and/or WINSCW!
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Error in QT Documentation

    Quote Originally Posted by tamhanna View Post
    MAAAN!

    I know it compiles for Windows. But it doesnt compile when using GCCE and/or WINSCW!
    That was Linux.

  6. #6
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: Error in QT Documentation

    The question is whether this is a bug in the Qt docs or actually a bug in GCCE. I think it is valid C++ to compare two pointers of different types. Probably the API shall better return QAbstractButtons everywhere but this cannot be changed for the Qt 4.xx series.

  7. #7
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Error in QT Documentation

    Hi,
    ok, I understand your point.

    But the core question is: if an user takes the code and pastes it, it doesnt work.And that IMHO shouldnt be!
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  8. #8
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Error in QT Documentation

    So, should we mention GCCE bugs in Qt documentation?

  9. #9
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Error in QT Documentation

    Hi,
    I, for my end, would just add the casts and let it be. We never know which other compilers might also act up.

    The casts IMGHO hurt no one if they are there. we can always add an explanation that they are there for some compilers - similar to some special tools for the MSVC.
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

Similar Threads

  1. Qt for Symbian development resources
    By liuxg in forum [Archived] Qt General ( Qt技术)
    Replies: 55
    Last Post: 2011-01-26, 04:06
  2. kinetic scrolling
    By stalep in forum Nokia N9
    Replies: 10
    Last Post: 2009-12-08, 12:41
  3. Senior QT Client Developer (Dublin, Ireland)
    By marynyc in forum News and Announcements
    Replies: 0
    Last Post: 2009-06-02, 18:24
  4. Suggestions to improve documentation for examples
    By heuven in forum Feedback - Nokia Developer Services & Infrastructure
    Replies: 0
    Last Post: 2008-12-06, 12:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×