Bring QProcess window to front (running Qt Assistant) - c++

My Qt application starts a QProcess that runs Qt Assistant.
I am using Linux (Ubuntu/Neon/KDE) but I want the Qt application to run on Windows and other Linux distributions as well.
Now I need a function that allows to bring the Assistant main window to front at the desktop.
I could not find a solution doing this using the QProcess object. Also I could not find a way to do this via Qt Assistant remote control.
How can I do this in a portable way?

If all you need is showing qhc help files along with your application, you can have a look at the Qt Help module, which is used by Assistant itself.
Instead of showing the help in an external application like the Qt
Assistant, it is also possible to embed the online help in the
application. The contents can then be retrieved via the QHelpEngine
class and can be displayed in nearly any form. Showing the help in a
QTextBrowser is probably the most common way, but embedding it in
What's This help is also perfectly possible.
More here

Related

Qt UI class (Clion)

I've been studying c++, but only for console application.
I'm trying to introduce myself in GUI applications with c++, since I'm working with CLion, I've noticed a Qt UI class, but I don't know how to use it.
Anyone know how to use this class, for create GUI apps (create events,...,).
I don't know if it's mandatory to install some extensions or not.
I'm a little bit lost in this area, so if anyone could help me, I would be grateful to you.
Well, maybe the Qt Creator IDE can be of help since the design of UI can be just dragging can editing so it is very friendly to starters.
Of course, you can edit the code Qt Creator generates.
As a matter of fact, I started working on Gt UI by dragging the components and got amazed at the 'talent' of me creating a simple GUI app in a minute!
Below is an example UI interface of Qt Creator. Have fun with Qt!

Integrating CLIPS with Qt

I've been trying to build a GUI with Qt. However, I have no idea how to integrate CLIPS with the signals and slots of Qt.
For example, in the GUI if a user presses ctrl+r it should run the source file entered. Similarly, the agenda has a different window which updates as the rules are loaded. How can I integrate all of this with Qt?
I'm also open to any ideas you may have about building a frontend for CLIPS.
Thanks
Take a look at CLIPSShell on SourceForge: https://sourceforge.net/projects/clipsshell/. It's written in Qt.

Filling text in qwidget using win32 api

I have a problem. I am using C++ to develop an application in Win32 that among other scopes automatize some user input process in an external app in order for the user to be ready to operate.
Particularly I would like to use Win32 API to fill some text in a Qt QWidget control. I wrote a DLL in pure C to get this task done. I tested it on a MFC application and it works very well.
Anyway I could not get it to work for Qt QWidget controls.
I was able to get the right handle via the EnumChildWindows function (stored in the struct Field).
SendMessage(Field.hFound,WM_SETTEXT,(WPARAM)NULL,(LPARAM)_T("bla bla bla"));
But the SendMessage doesn't seem to work because maybe the control (most probably a QLineedit) supports other messages to get this job done.
Is there any specification for these events, I googled a lot but I could not find anything suitable.
What is the most straightforward way to get this code working? Is there an Event table mapping for Qt I could use? Do I have to use some Qt headers and link it against a DLL (this could be a problem because of licensing)?
Thanks in advance.
Qt, at least 4.8 and 5.x, uses foreign controls. None of the widgets, beyond the window, have native handles. Your EnumChildWindows is most likely not finding what you think it's finding.
If you don't have access to the Qt application's source code, there's nothing else you can do, short of injecting your own code into the running application. If the application is dynamically linked, you can figure out what version of Qt it's using, and what compiler it was compiled with, and the likely set of Qt configuration options. You can then compile your own code with the same compiler and using same Qt version, and inject it into the running application. You can then enumerate visible windows, and their children, and find the control you're after.

QT How to embed an application into QT widget

In our project we have three independent applications, and we have to develop a QT control application that controls these three applications. The main window will be seperated to three sub windows - each one display another one application.
I thought to use QX11EmbedWidget and QX11EmbedContainer widgets, but two problems with that:
The QX11Embed* is based on X11 protocol and I dont know if it's supported on non-x11 systems like Windows OS.
Since QT 5 these classes are not existing, and the QT documentation doesn't mention why.
So that I dont know whether to use it or not - I'll be happy to get an answers.
In addition, I see that the QT 5.1 contains QWidget::createWindowContainer(); function that in some posts it looks like this should be the replacement to the X11Embed. Can anyone please explian me more how can I use this function to create a QT widget that will run another application (a Calculator for example) inside its?
I have searched a lot in Google, and didn't find answers to my Qs.
Can anyone please help me? Am I on the right way?
Thanks!
If all three independent applications are written with Qt, and you have their source, you should be able to unify them just through the parenting of GUI objects in Qt.
http://qt-project.org/doc/qt-4.8/objecttrees.html
http://qt-project.org/doc/qt-4.8/widgets-and-layouts.html
http://qt-project.org/doc/qt-4.8/mainwindows-mdi.html
If you don't have access to them in that way, what you are talking about is like 3rd party window management. It is kind of like writing a shell, like Windows Explorer, that manipulates the state and the size of other window applications.
Use a program like Spy++ or AutoIt Spy for Windows and the similar ones for other OS's, and learn the identifying markings of your windows you want to control, like the class, the window title, etc. Or you can launch the exe yourself in a QProcess::startDetached() sort of thing.
http://qt-project.org/doc/qt-5.1/qtcore/qprocess.html#startDetached
Then using the OS dependent calls control the windows. The Qt library doesn't have this stuff built in for third party windows, only for ones under the QApplication that you launched. There are a lot of examples of doing things like this by AutoHotKey, or AHK. It is a scripting language that is made for automating a lot of things in the windows environment, and there is port for Mac as well (though I haven't tried the mac port myself).
So in the end you are looking at finding your window probably with a call like this:
#include <windows.h>
HWND hwnd_1 = ::FindWindow("Window_Class", "Window Name");
LONG retVal = GetWindowLongA(hwnd_1, GWL_STYLE); // to query the state of the window
Then manipulate the position and state of the window like so:
::MoveWindow(hwnd_1, x, y, width, height, TRUE);
::ShowWindow(hwnd_1, SW_SHOWMAXIMIZED);
You can even draw widgets on top of the windows you are controlling if you set your window flags correctly for the windows you are manipulating.
transparent QLabel with a pixmap
Cannot get QSystemTrayIcon to work correctly with activation reason
Some gotchas that come up in Windows when doing all of this, is finding out the quirks of the Windows UI when they set the Display scaling different from what you expect, and if you want to play nice with the Task bar, and handling all the modal windows of your programs you are manipulating.
So overall, it is do-able. Qt will make a nice interface for performing these commands, but in the end you are looking at a lot of work and debugging to get it in a beautiful, reliable, window manager.
Hope that helps.
I never tried it myself, but from the docs in Qt 5.1 I would try QWindow::fromId(WId id), which gives you a QWindow, which should be embeddable with createWindowContainer:
QWindow * QWindow::fromWinId(WId id) [static] Creates a local
representation of a window created by another process or by using
native libraries below Qt.
Given the handle id to a native window, this method creates a QWindow
object which can be used to represent the window when invoking methods
like setParent() and setTransientParent(). This can be used, on
platforms which support it, to embed a window inside a container or to
make a window stick on top of a window created by another process.
But no guarantee. :-)

wxWidgets create an app that lives on the desktop?

Is it possible, using wxWidgets and C++, to create an application that will show on the desktop? What I mean, is that it would only display on the desktop, like Geektools, Rainmeter, etc.
Not out of the box.
You could try to get the HWND of the Desktop and create your own control in wxWidgets by deriving a class from wxControl or wxWindow and do the Drawing yourself. It is not that hard to do it :). You could even use wxHTMLWindow or wxWebConnect (3rdParty, based on Webkit) for that.
See GetDesktopWindow() for that:
http://msdn.microsoft.com/en-us/library/ms633504(VS.85).aspx
Assuming you are on Windows. You have to check for your WindowManagers Documentation on Linux yourself though. If you are using KDE, I would suggest to use QT directly or the KDE API. Same for Gnome.
It would be easier to use the corresponding os/windowmanager api for that though.
Hope that helps.