class InteractiveService :public QtService<QApplication>{public:
InteractiveService(int argc,char**argv);
~InteractiveService();protected:void start();void stop();void pause();void resume();void processCommand(int code);private:QLabel*gui;};
InteractiveService::InteractiveService(int argc,char**argv): QtService<QApplication>(argc, argv,"Qt Interactive Service"), gui(0){
setServiceDescription("A Qt service with user interface.");
setServiceFlags(QtServiceBase::CanBeSuspended);}
InteractiveService::~InteractiveService(){}void InteractiveService::start(){#if defined(Q_OS_WIN)if((QSysInfo::WindowsVersion&QSysInfo::WV_NT_based)&&(QSysInfo::WindowsVersion>=QSysInfo::WV_VISTA)){
logMessage("Service GUI not allowed on Windows Vista. See the documentation for this example for more information.", QtServiceBase::Error);
return;}#endif
qApp->setQuitOnLastWindowClosed(false);
gui =newQLabel("Service",0, Qt::WindowStaysOnTopHint| Qt::FramelessWindowHint);
gui->move(QApplication::desktop()->availableGeometry().topLeft());
gui->show();}void InteractiveService::stop(){delete gui;}void InteractiveService::pause(){if(gui)
gui->hide();}void InteractiveService::resume(){if(gui)
gui->show();}void InteractiveService::processCommand(int code){
gui->setText("Command code "+QString::number(code));
gui->adjustSize();}
Hi Ko,
I could compile qt service 2.6.1 with Qt4.7, Visual Studio 2008 and Window XP.
You might have problem with your environment , or forget ‘C:QtQtService2.6_1> configure -library’ before ‘qmake’.
If you want static library, you should do it without parameter ( ex) ‘C:QtQtService2.6_1> configure’ ).
hi guy, the InteractiveService app works fine to me, but i can’t debug the code in InteractiveService::start() function, what’s the matter with this problem?
2010年10月15日 @ 16:06:12
I tried to compile the qtservice framework. But after nmake, I got the list of errors.
I am using Qt4.7, Visual Studio 2008 and Window XP.
C:\Qt\QtService2.6_1>qmake
C:\Qt\QtService2.6_1>nmake
Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
cd buildlib\ && “C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nma
ke.exe” -f Makefile
Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
c:\Qt\Qt4.7WinCE\bin\qmake.exe -o Makefile buildlib.pro
“C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\nmake.exe” -f Makef
ile.Debug
Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
cl -c -nologo -Zm200 -Zc:wchar_t- -DDEBUG -D_DEBUG -Zi -MDd -EHs-c- -W3
-w34100 -w34189 -DUNDER_CE -DWINCE -D_WINDOWS -D_UNICODE -DUNICODE -D_WIN32 -DQT
_NO_PRINTER -DQT_NO_PRINTDIALOG -DARMV4I -D_ARMV4I_ -Darmv4i -D_ARM_ -DARM -D_M_
ARM -DARM -D__arm__ -DQ_OS_WINCE_WM -DQT_NO_PRINTER -DQT_NO_PRINTDIALOG -D_WIN32
_WCE=0x502 -DQT_QTSERVICE_EXPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD
_SUPPORT -DQT_NO_DYNAMIC_CAST -I”..\..\Qt4.7WinCE\include\QtCore” -I”..\..\Qt4.7
WinCE\include\QtGui” -I”..\..\Qt4.7WinCE\include” -I”..\src” -I”..\..\Qt4.7WinCE
\include\ActiveQt” -I”debug” -I”..\..\Qt4.7WinCE\mkspecs\default” -Fodebug\ @C:\
DOCUME~1\user\LOCALS~1\Temp\nm6.tmp
qtservice_win.cpp
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2260) : error C2
733: second C linkage of overloaded function ‘InterlockedIncrement’ not allowed
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2258) :
see declaration of ‘InterlockedIncrement’
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2267) : error C2
733: second C linkage of overloaded function ‘InterlockedDecrement’ not allowed
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2265) :
see declaration of ‘InterlockedDecrement’
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2275) : error C2
733: second C linkage of overloaded function ‘InterlockedExchange’ not allowed
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2272) :
see declaration of ‘InterlockedExchange’
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2286) : error C2
733: second C linkage of overloaded function ‘InterlockedExchangeAdd’ not allowe
d
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2283) :
see declaration of ‘InterlockedExchangeAdd’
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2295) : error C2
733: second C linkage of overloaded function ‘InterlockedCompareExchange’ not al
lowed
C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winbase.h(2291) :
see declaration of ‘InterlockedCompareExchange’
..\src\qtservice_win.cpp(718) : error C2065: ‘WM_ENDSESSION’ : undeclared identi
fier
NMAKE : fatal error U1077: ‘”C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
\cl.EXE”‘ : return code ‘0x2’
Stop.
NMAKE : fatal error U1077: ‘”C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN
\nmake.exe”‘ : return code ‘0x2’
Stop.
NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
Stop.
Is there solution for that?
Thanks
2010年10月15日 @ 19:48:36
Hi Ko,
I could compile qt service 2.6.1 with Qt4.7, Visual Studio 2008 and Window XP.
You might have problem with your environment , or forget ‘C:QtQtService2.6_1> configure -library’ before ‘qmake’.
If you want static library, you should do it without parameter ( ex) ‘C:QtQtService2.6_1> configure’ ).
OK?
2010年12月28日 @ 02:03:48
hi guy, the InteractiveService app works fine to me, but i can’t debug the code in InteractiveService::start() function, what’s the matter with this problem?