Results 1 to 7 of 7

Thread: I'm a fresh,how this problem could be resolved?

  1. #1
    Join Date
    Jul 2007
    Location
    china
    Posts
    4
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default I'm a fresh,how this problem could be resolved?

    here's the output in my terminal:
    (it's just a very simple hello,world program)


    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o hello.o hello.cpp
    hello.cpp: In function ‘int main(int, char**)’:
    hello.cpp:8: error: ‘class QApplication’ has no member named ‘setMainWidget’
    make: *** [hello.o] Error 1

  2. #2
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: I'm a fresh,how this problem could be resolved?

    Can you post your code? main()

  3. #3
    Join Date
    Jul 2007
    Location
    china
    Posts
    4
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: I'm a fresh,how this problem could be resolved?

    oh,sorry, I forget...
    here it is, I think it may be caused by the compatibility, for I installed the Qt4 on my machine, but the program is Qt3 version(got from the book <<C++ GUI Programming with Qt3>>):

    #include <QApplication>
    #include <QLabel>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QLabel *label = new QLabel("Hello Qt!", 0);
    app.setMainWidget(label);
    label->show();
    return app.exec();
    }

    and here the Qt installation on my Ubuntu 7.04 laptop:

    defyer@ubuntuyn:~$ dpkg -l |grep qt4
    rc libqt4-core 4.2.3-0ubuntu3 Qt 4 core non-GUI functionality runtime libr
    ii libqt4-core-kdecopy 4.3.0~beta1-0ubuntu2 Qt 4 core non-GUI functionality runtime libr
    ii libqt4-dev-kdecopy 4.3.0~beta1-0ubuntu2 Qt 4 development files
    rc libqt4-gui 4.2.3-0ubuntu3 Qt 4 core GUI functionality runtime library
    ii libqt4-gui-kdecopy 4.3.0~beta1-0ubuntu2 Qt 4 core GUI functionality runtime library
    rc libqt4-qt3support 4.2.3-0ubuntu3 Qt 3 compatibility library for Qt 4
    ii libqt4-qt3support-kdecopy 4.3.0~beta1-0ubuntu2 Qt 3 compatibility library for Qt 4
    rc libqt4-sql 4.2.3-0ubuntu3 Qt 4 SQL database module
    ii libqt4-sql-kdecopy 4.3.0~beta1-0ubuntu2 Qt 4 SQL database module
    rc qt4-designer 4.2.3-0ubuntu3 Qt 4 Designer
    ii qt4-designer-kdecopy 4.3.0~beta1-0ubuntu2 Qt 4 Designer
    ii qt4-dev-tools-kdecopy 4.3.0~beta1-0ubuntu2 Qt 4 development tools
    ii qt4-doc-kdecopy 4.3.0~beta1-0ubuntu2 Qt 4 API documentation
    ii qt4-qtconfig-kdecopy 4.3.0~beta1-0ubuntu2 Qt 4 configuration tool

    thank u!

  4. #4
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: I'm a fresh,how this problem could be resolved?

    remove //app.setMainWidget(label);

    QApplication::setMainWidget() is no longer used in Qt4. When all an application's windows are closed, the application will exit normally.

  5. #5
    Join Date
    Jul 2007
    Location
    china
    Posts
    4
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: I'm a fresh,how this problem could be resolved?

    yes, it works, thanks
    so, I'd better to use Qt3 to compile the program from that book?
    if I put more than one widgets, what comes? is that necessary to "setMainWidget"?if not , what shoud I do?

  6. #6
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: I'm a fresh,how this problem could be resolved?

    you create mainWindow object in main or any user define class object in main. then you add widget in mainWindow or your defined class.
    you can see example from http://doc.trolltech.com/4.3/examples.html

  7. The following user says thank you to rajesh for this useful post:

    defyer (16th July 2007)

  8. #7
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: I'm a fresh,how this problem could be resolved?

    Quote Originally Posted by defyer View Post
    yes, it works, thanks
    so, I'd better to use Qt3 to compile the program from that book?
    if I put more than one widgets, what comes? is that necessary to "setMainWidget"?if not , what shoud I do?
    Or choise a qt4 book..

    Your existing qt3 code can transform to qt4
    http://doc.trolltech.com/4.2/qt3to4.html
    qt3to4 myapp.pro

    Tip: compile self the package.. to best performance
    http://www.qtforum.de/forum/viewtopic.php?t=4044
    [HTML]
    apt-get source libqt4-core
    ## get dependency
    apt-get build-dep libqt4-core
    apt-get install fakeroot
    cd qt*
    dpkg-buildpackage -us -uc -rfakeroot
    [/HTML]

Similar Threads

  1. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.