【问题标题】:Qt Assistant: How to maximize help window, when QT-Assistent is started as processQt Assistant:如何最大化帮助窗口,在 QT-Assistant 中作为进程启动
【发布时间】:2014-09-25 23:22:50
【问题描述】:

QT4.8

嗨, 我正在使用 QProcess 模式连接到 QT-Assistent。

例如(来自 QT 文档)

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。

【问题讨论】:

    标签: c++ qt


    【解决方案1】:

    如果您启动另一个进程,则需要使用特定于操作系统的 windows 管理工具。

    您通常可以在创建进程时获取窗口 ID,但管理其窗口是特定于平台的。

    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);
    

    希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-15
      • 1970-01-01
      • 2010-10-07
      • 1970-01-01
      • 2017-04-04
      • 2020-12-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多