PDA

View Full Version : not running the application program



sudheer
4th December 2007, 09:49
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


#include<QtGui>
#include<QtCore>
#include<QApplication>
#include"ui_MainWindow6.h"


class image6 : public QMainWindow,private Ui::MainWindow6

{
Q_OBJECT

public:

image6::image6()
{
setupUi(this);

connect(pushButton1,SIGNAL( click() ),this,SLOT( startxterm() ));
}

private slots:

void image6::startxterm()

{
// QProcess *proc;
proc = new QProcess( this );
// proc->start("/usr/bin/xterm");
proc->execute("/usr/bin/xterm");
}

private:
QProcess *proc;

};


int main( int argc, char *argv[] )
{
QApplication app(argc,argv);
image6 *dialog6 = new image6;
dialog6->show();
return app.exec();
}

#include "main.moc"


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

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

marcel
4th December 2007, 10:23
execute is static in QProcess, so there's no need to use it with an instance.
What does execute returns?

Khal Drogo
4th December 2007, 10:27
I think the problem is that click() is not a signal, its a slot.
Try changing the click() to clicked().

sudheer
4th December 2007, 10:27
it returns nothing

marcel
4th December 2007, 10:33
I think the problem is that click() is not a signal, its a slot.
Try changing the click() to clicked().
Yes, that's it.

sudheer
4th December 2007, 10:58
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 ........................................

ChristianEhrlicher
4th December 2007, 11:03
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.

sudheer
4th December 2007, 12:09
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

ChristianEhrlicher
4th December 2007, 12:26
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!

sudheer
5th December 2007, 07:40
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

sudheer
5th December 2007, 08:19
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?????

ChristianEhrlicher
5th December 2007, 08:35
Yes, that's correct

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