I am trying to extend a legacy win32 application functionalities. The legacy application has a Multiple Document Interface(MDI) as it's main window and is purely written in win32 API. Is it possible to show a QWidget in win32 MDI area as a child?
Are you using MFC?
What's important to understand is that running Qt always requires you have a running Qt event loop. So what you need is to properly process your MFC/win32 events an the Qt events.
There is the Qt solution QtWinMigrage for that supports Qt 4 and Qt >= 5.4 (Qt 5.0-5.3 are broken). Examples also show your use case.
This is certainly a good starting point if your application is based on CWinApp.
Further details can be found by searching the internet and reading about the QAbstractEventDispatcher. Hope this helps!
Related
I'm trying to get QtWebEngine running on a VM and am having difficulties. According to the answer to this question:
Eventually I realised that OpenGL 3.3 wouldn't work easily on virtual machines .. yet. I had to boot from ubuntu usb and work from there by installing latest mesa 3d package.
Is there a way to get QtWebEngine to work without OpenGL? I'm not directly using any OpenGL calls, nor do I need any 3d capabilities. I just want to embed a QWebEngineView to display dynamic HTML pages. I'm guessing this should be possible since Chrome works on the same VM without an issue.
I don't think there is a way to use the Qt WebEngine without OpenGL. It is not very explicitly said in the documentation, but here's what I understood from what I found.
About Chromium
As it is said here, QtWebEngine integrates chromium's fast moving web capabilities into Qt. Plus, it is Chromium that allows the manipulation of OpenGL via the Qt Quick scene graph (source) :
Chromium is tightly integrated to the Qt Quick scene graph, which is
based on OpenGL ES 2.0 or OpenGL 2.0 for its rendering. This provides
you with one-pass compositing of web content and all the Qt Quick UI.
The integration to Chromium is transparent to developers, who just
work with Qt and JavaScript.
It is also said that both the render process and the GUI process should share an OpenGL context :
Because the render process is separated from the GUI process, they
should ideally share an OpenGL context to enable one process to access
the resources uploaded by the other, such as images or textures.
About the Qt WebEngine itself
We just talked about the Qt's GUI : in fact, the Qt WebEngine is not dependent of this GUI (page rendering and JavaScript execution are separated from the GUI process into the Qt WebEngine process), but remember that if you want your application to work, you will need to share an OpenGL context between both processes. In particular, this is achieved by default with a QSurfaceFormat, which has a OpenGLContextProfile accessible by the function QSurfaceFormat::profile(). Now, we look back at the Qt WebEngine platform notes which states :
If a new default QSurfaceFormat with a modified OpenGL profile has to
be set, it should be set before the application instance is declared,
to make sure that all created OpenGL contexts use the same OpenGL
profile.
On OS X, if the default QSurfaceFormat is set after the application
instance, the application will exit with qFatal(), and print a message
that the default QSurfaceFormat should be set before the application
instance.
If we look at the source code of Qt, calls to OpenGL are made in several important files, like qtwebengine\src\core\web_engine_context.cpp or qtwebengine\src\webengine\api\qtwebengineglobal.cpp. Moreover, I also found calls to OpenGL in functions from the sources in qtwebengine\src\3rdparty\chromium\, so I suspect that Chromium needs to call OpenGL functions sometimes.
In short
The Qt WebEngine is using Chromium (which doesn't necessarily use OpenGL) and also Qt GUI, which uses an OpenGL context which has to be shared by the Web Engine. Thus, my conclusion is that you can't use the Qt WebEngine without OpenGL.
I had the same problem on my VM environment trying to start an application that uses QtWebEngine and it crashed.
I will add this answer as a reference - although Sergey Khasanov mentioned it already in the comment above
Use Software Qt Quick2DRenderer - see https://doc.qt.io/QtQuick2DRenderer/
To do that, simply set the environment variable:
export QMLSCENE_DEVICE=softwarecontext
then restart your application. It might still complain about
libEGL warning: GLX/DRI2 is not supported
libEGL warning: DRI2: failed to authenticate
but (in my case) it finally worked!
I am trying to develop a user interface using QtCreator on a Windows 7 64-bit machine. This user interface will be deployed on a 32-bit Windows 7 machine, and will control a projector and a camera for a structured-light application. For reasons beyond my control (compatibility with camera and projector's APIs), I will use the MS VS 2010 32bit compiler for this. After a couple of weeks trying to have everything I need working together (Qt 4.8.4, QtCreator and Point Cloud Library), I am now facing a slight problem.
Is there a way that I can embed the PCL Point Cloud Viewer inside my main Qt GUI window? The problem is that when I use the PCL viewer, it brings up a separate window. I want this window to be embedded inside my main window, and I want to still be able to interact with it (rotate, pan, zoom, etc.).
As you may be able to tell from my post, I am a newbie on Qt/PCL/etc., so any example with minimal code to do this would be greatly appreciated. I have done weeks of research on this and I have not been able to find a solution, although I get the impression that a Qt Widget might be the way to go.
You can simply use PCL's PCLVisualizer, which is extensively described here, via the QVTKWidget. This is the setup I'm currently running. So you would end up doing something along the lines of the following (pseudo-)code:
In your header:
class PointCloudWidget : public QVTKWidget
{
//Whatever comes before (constructor, methods, etc.)
private:
pcl::visualization::PCLVisualizer m_visualizer;
};
And in your cpp:
PointCloudWidget::PointCloudWidget(QWidget *parent) : QVTKWidget(parent)
{
this->SetRenderWindow(m_visualizer.getRenderWindow());
}
You can then use the visualizer to achieve the same functionality as the PCL viewer has.
Look at the kind of minimal code I put here (PCL Viewer with Qt GUI minimal code).
There are some redundancies, but the code I believe is pretty straightforward.
The main idea is to put the files in the one folder and start project from CMakeLists.txt (Qt cmake wizard).
I use build directory inside project dir. (this is important, because in pclwindow.cpp I hardcoded the path to the generated file #include "build/ui_pclwindow.h"
If app builds, but crashes you'll probably need to add some dependencies (e.g. dll files on Win platform)
I hope it will give you fast and simple start!
I'm trying to create some kind of a server which allows me to start Qt's applications on remote machine via web browser.
I'm wondering it is possible to change/hide some symbols from Qt library (I thought about QApplication or QCoreApplication) without making any changes in code of application (I assume that it is already compiled and uses Qt shared library) and compiling my whole tailor-made Qt libs?
The reason why I need to do this is because I want to install my own specific EventFilter to QApplication and also be able to push my own created events to Qt application.
It also would be great if the solution could be used on all platforms :D
P.S. I know that it will not be possible I could subclass QApplication and modify all Qt apps to use my derived class but I would like to do this more craftily. ;-)
The tool GammaRay does all kinds of injecting code into Qt methods at runtime to attach and debug running Qt applications. You might want to have a look at its code base to see how it is done.
How can I make my application appear in the system tray?
I already have a QDialog widget with parent as qApp->mainWidget() and disabled the task bar entry. Now I need it to appear in the system tray.
I am using Qt 3.3
I'll start by saying you're probably wasting your time. I can't seem to find anything in the Qt 3.3 documentation which alludes to what you want. However in Qt 4.8 there is a QSystemTrayIcon class, which was introduced in Qt 4.2.
Normally, when a new class replaces an old class the Qt documentation says so, therefore I doubt any code was written to handle system tray icons across the supported platforms in 3.3.
Furthermore, even if you do find something in 3.3, it's unlikely it will work now as most OSes are likely to have changed their GUIs since then.
My answer? Update to 4.8 and use QSystemTrayIcon.
I need to trigger a phone call from a Qt application. I looked to previous post without find a complete answer.
I need to make it with qt 4.6.3. I'm quite new to symbian development, I'm using the last nokiaSDK.
It MUST work ONLY on n97 and E71.
Can Anybody provide a solution?
May be a solution exec an extenal process using QProcess?
It seems like currently none of Qt APIs (including QtMobility) allows to do it. However, you can use native Symbian C++ API - CTelephony class. There are some examples showing how to make a phone call using this class. The obvious disadvantage is that it won't work on any other platform than Symbian.
You may be interested in this example: http://library.forum.nokia.com/topic/Qt_for_Symbian_Developers_Library/GUID-B4DA6005-3037-4FF8-82D5-BA748532E648.html#GUID-B4DA6005-3037-4FF8-82D5-BA748532E648. It shows how to mix Symbian C++ code with Qt code, and it also uses CTelephony, so you just need to change method call from GetPhoneId() to DialNewCall(). Don't forget to add appropriate library (etel3rdparty.lib) in your .pro file.