2014-09-25 29 views
0

QT4.8的Qt助手:如何當QT-助理開始的過程

嗨, 我連接到QT-助理使用QProcess中的模式最大化幫助窗口。

例如(從QT DOC)

QProcess *process = new QProcess; 
QStringList args; 
args << QLatin1String("-collectionFile") 
    << QLatin1String("mycollection.qhc") 
    << QLatin1String("-enableRemoteControl"); 
process->start(QLatin1String("assistant"), args); 
if (!process->waitForStarted()) 
    return; 

,我通過使用建議的文件傳遞命令它:

QByteArray ba; 
ba.append("setSource qthelp://com.mycompany.1_0_0/doc/index.html\n"); 
process->write(ba); 

我的問題:

如何最大限度地幫助窗口,以防用戶最小化? 由於幫助按不同的過程運行,因此沒有找到一種方法來啓動窗口。

TIA。

回答

1

如果啓動另一個進程,則需要使用操作系統特定的窗口管理工具。

當創建進程時,您通常可以獲取窗口標識,但管理其窗口是特定於平臺的。

的Qt一直沒有離開過它的應用範圍做跨平臺的全shell訪問,但這裏是你會怎麼做它在Windows中:

http://qt-project.org/doc/qt-5/qprocess.html#processId

http://forums.codeguru.com/showthread.php?353149-How-to-Get-windows-Handle-using-Process-Id

https://stackoverflow.com/a/10258861/999943

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx

#include <windows.h> 

//... 

HWND h = ::GetTopWindow(0); 
{ 
    DWORD pid; 
    DWORD dwTheardId = ::GetWindowThreadProcessId(h,&pid); 

     if (pid == process->processId()) 
     { 
       // here h is the handle to the window 
       break; 
     } 
     h = ::GetNextWindow(h , GW_HWNDNEXT); 
} 

::SetForegroundWindow(h); 

::ShowWindow(h, SW_SHOWMAXIMIZED); 

希望有幫助。