0

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.

Theo
  • 1,385
  • 2
  • 10
  • 19

1 Answers1

1

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

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

Hope that helps.

Community
  • 1
  • 1
phyatt
  • 18,472
  • 5
  • 61
  • 80