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.
Related
I am beginner in web assenbly and I want to use qt webassembly in qml application. I use emsdk 1.38.30-64bit to compile qml application and it compile successfully but when I use emsdk 1.38.30-64bit with thread flag in my browser I get downloading/compiling. what is my mistake and how should I solve this problem?
Qt multi-thread support is still quite in development, a single thread application should be in general fine for QML apps, the QML engine is still single threaded. Try also newer emscripten compilers, but even in my extensive testing with versions 1.39+ multi-thread was an issue. Quick note if you want to test your QML app in the browser, you can use Felgo WebEditor for quick snippet testing https://felgo.com/web-editor or you can test our fully fledged web IDE https://ide.felgo.com
The Android application I am about to work on has the UI in Java and the non-UI functionality in C++ that would be accessed via JNI. The C++ code uses some non-UI Qt classes. I am thinking I will spawn a thread in JNI_OnLoadthat essentially will instantiate and run QCoreApplication. Any subsequent JNI call will simply post an event to this thread. Is this possible? Regards.
What you want to do is definitely possible but a bit more difficult than it seems initially.
If you build your app end to end in Qt there's a lot of functionality you get for free from their framework that allows it to run on Android and a lot of that functionality/plumbing is wrapped up in their UI. So if you're not using their UI there's extra work that you need to do.
On Android their UI framework basically creates a native Activity and then uses that activity as a wrapper for the app. If you look at the low-level source for their UI thats what's happening on Android and it's what allows the Qt app to access local resources, the network, OS facilities, etc.
Without the Activity wrapper, your app will only be able to do simple, in-memory operations that require no OS, file system, or network access and also won't be able to make use of other Qt libraries(eg Qt5Sql, Qt5Core, etc).
Here's what we had to do to make this work in our java app:
Create a proxy wrapper Activity for Qt to use that shares the base
context of your app.
Create a QtActivityDelegate.
Set the proxy activity and delegate using the native Qt android
libraries. eg QtNavite.setActivity.
Instantiate and set a DexClassLoader using the same native Qt android libraries.
Load any Qt libraries using System.loadLibrary(..). Please note that the libraries need to be present on the file system already. This part was a big pain for us.
For your Qt Code, make sure you have proper wrappers written so that they can be used via jni. We ended up using swig to auto-generate java wrappers for our code.
You can find out more about swig here: http://swig.org/
After all that you should be able to use your Qt class/library from within a native Android app.
Painful but definitely possible!
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 am working on an simple c++ application for my work that needs to run both on Windows and on Linux. When running on Windows it should display a simple GUI and when running on Linux it should use a textual UI (because the Linux computer don't use any GUI at all).
I was wondering if I could use Qt to write the app (since its cross platform) and replace the GUI usage on Linux with printouts to STDOUT using "#ifndef WIN32"?
Any other suggestions would be appreciated. The program reads some properties from an xml file and runs some tests according to those properties (access sockets, environmental vars etc.). My goal is to write a single project that would be statically compiled (to get an undependable executable) for each platform and avoid creating different projects.
Thank you.
It's certainly possible, but try to avoid #ifdefs as much as possible.
One approach is to isolate all the core features (data processing, networking etc...) in non-GUI classes. Then you write two sets of classes for presentation: one based on QWidgets, the other one that just does text input/output.
To wrap it up, use an #ifdef in you main() to select which "presentation" classes to use (and switch between QCoreApplication for non-GUI and QApplication for GUI).
Don't base that #ifdef on WIN32, use a custom variable. That way you can run and test both versions in the environment you're more familiar with.
I have a pre-existing application, that calls out into a plugin library. I want the plugin library to be developed in Qt, and to be able to display a Qt UI.
However, when I attempt to create a QWidget it complains that the QApplication needs to be created first.
Is it not possible to use Qt to develop cross platform plugins?
E.g. a netscape plugin for Chrome or Firefox. I do not, and cannot, control the app's main loop.
As explain in the Qt documentation, any GUI application using Qt needs a QApplication to be created into main thread since it is containing all signal engine and event loop.
There is Qt/MFC Migration Framework that can help you to build plugins if the main application where the plugin is laoded is Win32 or Mfc. Qt/MFC Migration Framework