本文介绍了Qt助手:当QT-Assistent作为进程启动时,如何最大化帮助窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

QT4.8



您好,
我使用QProcess模式连接到QT-Assistent。



例如(来自QT文档)

  QProcess * = 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\\\
);
process-> write(ba);

我的问题:



如何最大化帮助窗口,以防用户最小化?
由于帮助是作为不同的进程运行的,没有找到一个方法来使窗口向上。



TIA。



如果您启动另一个进程,则需要使用Windows操作系统特定的管理工具。 >你通常可以在创建进程时获取窗口ID,但是管理它的窗口是平台特定的。



Qt没有离开它的应用程序范围做完整的shell访问但这里是您在Windows中执行的操作:









  #include< ; windows.h> 

// ...

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

if(pid == process-> processId())
{
//这里h是窗口的句柄
break;
}
h = :: GetNextWindow(h,GW_HWNDNEXT);
}

:: SetForegroundWindow(h);

:: ShowWindow(h,SW_SHOWMAXIMIZED);

希望有帮助。


QT4.8

Hi, I am connecting to QT-Assistent using a QProcess schema.

For example (from the 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;

and I am passing commands to it by using the suggested documentation:

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

My Problem:

How to maximize the help window, in case user minimizes it?Since the help is running as different process, did not find a way to bring the window up.

TIA.

解决方案

If you launch another process, you are then required to use OS specific management tools of the windows.

You can often get the window id when the process is created, but managing its window is platform specific.

Qt hasn't left its application scope to do full shell access across platforms, but here is how you would do it in 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

http://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);

Hope that helps.

这篇关于Qt助手:当QT-Assistent作为进程启动时,如何最大化帮助窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 06:45