Programs Using QT



  • I have post some of the programs using QT framework.
    Please go through the posts and give your feed back.
    http://www.boostprogramming.com/forum/index.php/board,178.0.html


  • Moderators

    Hi,

    I've browsed roughly through some of the examples and my overall impression is that they complicate things unnecessarily.

    For example the hello world program:
    @
    QApplication a(argc, argv);
    boost::shared_ptr < QLabel > QLabelPtr ( new QLabel("<h2>Hello ""<font color=red>World!</font></h2>") ) ;
    QLabelPtr ->show () ;
    return a.exec();
    @
    I mean - what is the point here?
    Why another giant library (boost) just for the shared_ptr when there's QSharedPointer already in Qt?
    Why a pointer at all?
    In case of hello world this would be a lot easier:
    @
    QApplication a(argc, argv);
    QLabel label("<h2>Hello <font color=red>World!</font></h2>") ;
    label.show () ;
    return a.exec();
    @

    Another example:
    @
    if ( daysRemaining == 0 )
    {
    std::cout << d2.toString().toStdString() << " is Monday " << std::endl;
    }
    else if ( daysRemaining == 1 )
    {
    std::cout << d2.toString().toStdString() << " is Tuesday " << std::endl;
    }
    else if ( daysRemaining == 2 )
    {
    ...
    @
    This is terrible! Why not simply:
    @
    QVector days;
    days << "Monday" << "Tuesday" << ...
    std::cout << ... << days[daysRemaining] << ...
    @

    One more:
    @
    QList<QString> list ;
    list.push_back ("Kranthi");
    list.push_back ("Kumar");
    list.push_back ("Reddy");
    QList<QString>::const_iterator listIter = list.begin();
    while (listIter != list.end() )
    {
    std::cout << listIter->toStdString().c_str() << std::endl;
    listIter ++ ;
    }
    @
    Again this can be greatly simplified:
    @
    QList<string> list ;
    list << "Kranthi" << "Kumar" << ...
    foreach(const string& s, list)
    cout << s.c_str() << endl;
    @
    Or even:
    @
    QStringList list;
    list << "Kranthi" << "Kumar" << ...
    qDebug() << list;
    @
    There are lots and lots of things like that. I just don't have time to look at them all but I'm afraid they mostly need a rewrite.




Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.