Results 1 to 12 of 12

Thread: not running the application program

  1. #1
    Join Date
    Nov 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    11

    Post not running the application program

    hello all, i had made simple dilalog form in Qt designer and in that form i put the single pushbutton , then i wanted to run a application program by clicking the pushbutton

    but it is not running, and my code is like this

    Qt Code:
    1. #include<QtGui>
    2. #include<QtCore>
    3. #include<QApplication>
    4. #include"ui_MainWindow6.h"
    5.  
    6.  
    7. class image6 : public QMainWindow,private Ui::MainWindow6
    8.  
    9. {
    10. Q_OBJECT
    11.  
    12. public:
    13.  
    14. image6::image6()
    15. {
    16. setupUi(this);
    17.  
    18. connect(pushButton1,SIGNAL( click() ),this,SLOT( startxterm() ));
    19. }
    20.  
    21. private slots:
    22.  
    23. void image6::startxterm()
    24.  
    25. {
    26. // QProcess *proc;
    27. proc = new QProcess( this );
    28. // proc->start("/usr/bin/xterm");
    29. proc->execute("/usr/bin/xterm");
    30. }
    31.  
    32. private:
    33. QProcess *proc;
    34.  
    35. };
    36.  
    37.  
    38. int main( int argc, char *argv[] )
    39. {
    40. QApplication app(argc,argv);
    41. image6 *dialog6 = new image6;
    42. dialog6->show();
    43. return app.exec();
    44. }
    45.  
    46. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    ******************************************

    and while making it giving some warning as

    /usr/local/Trolltech/Qt-4.3.2/bin/moc -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.3.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.3.2/include/QtCore -I/usr/local/Trolltech/Qt-4.3.2/include/QtCore -I/usr/local/Trolltech/Qt-4.3.2/include/QtGui -I/usr/local/Trolltech/Qt-4.3.2/include/QtGui -I/usr/local/Trolltech/Qt-4.3.2/include -I. -I. -I. main.cpp -o main.moc
    main.cpp:30: Warning: Function declaration image6::startxterm contains extra qualification. Ignoring as signal or slot.
    g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.3.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.3.2/include/QtCore -I/usr/local/Trolltech/Qt-4.3.2/include/QtCore -I/usr/local/Trolltech/Qt-4.3.2/include/QtGui -I/usr/local/Trolltech/Qt-4.3.2/include/QtGui -I/usr/local/Trolltech/Qt-4.3.2/include -I. -I. -I. -o main.o main.cpp
    g++ -Wl,-rpath,/usr/local/Trolltech/Qt-4.3.2/lib -o filebrowser6 main.o -L/usr/local/Trolltech/Qt-4.3.2/lib -lQtGui -L/usr/local/Trolltech/Qt-4.3.2/lib -L/usr/X11R6/lib -lpng -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lXfixes -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lglib-2.0 -lrt -ldl -lpthread
    Last edited by marcel; 4th December 2007 at 10:15. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: not running the application program

    execute is static in QProcess, so there's no need to use it with an instance.
    What does execute returns?

  3. #3
    Join Date
    Nov 2007
    Posts
    51
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Default Re: not running the application program

    I think the problem is that click() is not a signal, its a slot.
    Try changing the click() to clicked().

  4. #4
    Join Date
    Nov 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    11

    Post Re: not running the application program

    it returns nothing

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: not running the application program

    Quote Originally Posted by Khal Drogo View Post
    I think the problem is that click() is not a signal, its a slot.
    Try changing the click() to clicked().
    Yes, that's it.

  6. #6
    Join Date
    Nov 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    11

    Post Re: not running the application program

    Khal Drogo --------------

    yes ur right, that signal should be clicked() instead click()

    but though i changed the signal name properly, application is not running

    any more suggessions ........................................

  7. #7
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 86 Times in 81 Posts

    Default Re: not running the application program

    Q_OBJECT / class definition should be in a header and not in source file. Otherwise qmake/moc will not recognize Q_OBJECT macro.
    Move it to a header and add it to HEADERS in your pro-File.

    /edit: Also you'll see a Qt warning on executing your programm (after you clicked on your button) which points you to this problem.

  8. #8
    Join Date
    Nov 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    11

    Unhappy Re: not running the application program

    Quote Originally Posted by ChristianEhrlicher View Post
    Q_OBJECT / class definition should be in a header and not in source file. Otherwise qmake/moc will not recognize Q_OBJECT macro.
    Move it to a header and add it to HEADERS in your pro-File.

    /edit: Also you'll see a Qt warning on executing your programm (after you clicked on your button) which points you to this problem.


    i also tried like u said but it din't works

    again giving warning as usaully

  9. #9
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 86 Times in 81 Posts

    Default Re: not running the application program

    And you should learn a little bit c++

    image6::image6() in a class definition is not needed (and some compiler refuse this)

    just use
    image6()
    and separate implementation and definition of the class!

  10. The following user says thank you to ChristianEhrlicher for this useful post:

    sudheer (5th December 2007)

  11. #10
    Join Date
    Nov 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    11

    Smile Re: not running the application program

    ChristianEhrlicher ------------------------

    heyyy sorry friend, for my last post, actually ur right. I divide the project into 3 files (.h,.cpp,main.cpp) but wat the mistake i does is ----- in header file's class declaration
    i am declare member fun' with class name

    now i am able run my application very easily

    thanks

  12. #11
    Join Date
    Nov 2007
    Posts
    42
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    11

    Default Re: not running the application program

    and one more thing I forgot that , in my above program ther is no need of putting scope operator( :: ) with class name since withing the class declaration i have define member function. so whenever the member function define outside class declaration we should use
    the scope operator

    ya my correct ChristianEhrlicher?????

  13. #12
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 86 Times in 81 Posts

    Default Re: not running the application program

    Yes, that's correct

    foo::foo() inside a class definition is not needed / can confuse the compiler or moc from Qt

Similar Threads

  1. Detect platform where my QT4 program is running on
    By the_bis in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2007, 13:01
  2. Replies: 10
    Last Post: 11th June 2007, 10:18
  3. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 05:19
  4. Replies: 1
    Last Post: 17th May 2006, 01:23
  5. Replies: 5
    Last Post: 16th January 2006, 06:15

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
  •  
Qt is a trademark of The Qt Company.