please note that I am not a native in English. sorry for any mistake.
I am very new to QT(just started yesterday) and have only few experiences with MFC.
I want to know how to integrate QT GUI DLL into non QT application.
I made this QT GUI DLL from the wizard: I simply chosen QT Gui Application and in .pro I changed "TEMPLATE = app" to "TEMPLATE = lib", as well as changing source code.
I attached source code here, you may looks at it.
http://cfile208.uf.daum.net/attach/025A524151C3E65D1B5E63
in the zip file, sources in folder "gui" does creating GUI DLL.
sources in folder "main" actually loads DLL and try to call the function in DLL.
they compiles well, but it seems they do not work. it gets an error called "there should be only one application object" when I start main.exe
What is the problem?
Don't create QApplication object in your library. There must be only one QApplication object, and it's already created by the main app.
If you need to access QApplication object from your library, use qApp macro to obtain a pointer to the QApplication.
Related
I have a reMarkable tablet , which I mostly love except for the lack of linux support (surprising given it is a linux-based OS). However, I've managed to find a version of a linux application that is now unofficial. This github is actually a Qt docker app, but if you look in the code for the 'Dockerfile' you can find where to download the app, which is apparently still on the server even though there's not a link from the main web page. Anyway, I downloaded it and got it mostly working, figuring out a few dependencies based on same Dockerfile code. But, I can't seem to get file dialogs to work, which is the main reason for using the app.
The error I get is:
ERROR: No native FileDialog implementation available.
Qt Labs Platform requires Qt Widgets on this setup.
Add 'QT += widgets' to .pro and create QApplication in main().
I'm not a Qt developer, so I'm lost. I'd love to get this to work. Thanks.
In the .pro file of you project you should add this line QT += widgets
or just add widgets to the line with QT += ...
Qt can use native file dialogs on some platforms, and will fall back to its own implementation if none is available. But that requires that the application is built including the QtWidgets module, and using a QApplication.
If you don't have the source code of the app and a possiblity to rebuild it, there's no chance to fix this from a binary
I'm using Qt 5.5 to create a small app. In the app, I'm manually creating a component like so:
QQmlComponent component(engine, QUrl("qrc:/Box.qml"));
assert(component.isReady());
My .qrc file IS included in the .pro file like so:
RESOURCES += qml.qrc
All works well when I run from Qt creator. However, when I deploy the app using the macdeployqt tool and try to run the app I get that assert hit. Sure enough, I tried to put a loop around the .isReady() and it will hang forever.
What is the proper way for doing this? My qml component is working fine when in the Qt creator, so why does it fail in deployment?
Thanks
This turned out to be simple. You need to pass -qmldir=<path to your qml files> to macdeployqt. It is actually required if you have QML files but I somehow didn't see it in the documentation.
How can I import these code examples into QT Creator 3.4.0 ? I tried the available import options but they don't work.
I tried to create an empty QML project and add the rectangle.qml file to it. When I tried to run it, nothing showed up.
The book examples contain files .qmlproject - which seems to be a project descriptor. I wonder if it is somehow possible to import these .qmlproject files into QT Creator, click and run the examples.
I think this link might help in finding the solution : https://forum.qt.io/topic/27525/what-is-qmlproject-file/3 .
Usually I'd say that you should go to File > Open File or Project... and select the .qmlproject and you're done, but support for this type of project file was disabled by default. If you try to do this now (I believe the change is in Creator 3.4), you'll just get an error message about Creator not supporting the mime type of the file, or something. Unfortunately, this is not a very useful error message for a beginner, and it won't tell you how to fix the problem.
If you want to use .qmlproject files in newer versions of Creator, you have to navigate to Help > About Plugins... and enable the QmlProjectManager plugin (it's under the Qt Quick section) by checking the box.
So this is how you should normally open project files in Qt Creator. As for the window not showing up, that's also commonly encountered and can be fixed by making the root item in your scene a Window:
Unlike QQuickView, QQmlApplicationEngine does not automatically create a root window. If you are using visual items from Qt Quick, you will need to place them inside of a Window.
Qt Creator's new project wizard handles this for you when you create a new Qt Quick project, as you saw when you got the "Hello World" window to open in your video. It was when you loaded concepts/rectangle.qml which had a Rectangle as its root item, that it stopped showing up. That QML file was likely used in a project where a QQuickView was displaying it.
I have created a DLL that uses some functionality from QTWebKit, that I then access through JNA on the java side. On my machine (which QT is installed on obviously) it works fine. When I move it to another machine to to test it that does not have qt installed I get:
Failed to load platform plugin "windows". Available platforms are:
My google fu as pointed me to the fact that I need to also include platform DLLs, namely qwindows.dll and qminimal.dll. According to the QT5 documentation in Deploying an Application on Windows it sounds like when deploying an executable it would be in a folder called platforms in the save directory as the executable.
In contrast to user plugins, Qt plugins have to be put into
subdirectories matching the plugin type. As we want to deploy the
windows platform plugin it has to be put into a "platforms"
subdirectory.
That leads me to my dilemma. I have a dll, not an executable. So I have no clue where to put the platform folder. I have tried to place it in the same directory I am executing my test application, but that did not work.
So where do I place the platform directory in order for QT to be able to find it?
Edit:
Since I have not had much feedback, maybe there is a better way to word/approach this question.
How do I tell QT where to find the platform DLLs?
It seems like there has to be a way to accomplish this. When I run it on my machine, it ends up looking in C:\Qt2\Qt5.0.2\5.0.2\msvc2012_64\plugins\platforms. So it seems there m
I have found two possible solutions for the scenario that you need to create a QApplication inside a DLL or library (basically different from the normal create Qt application that has an exe).
The easiest solution is to set the system environment variable QT_QPA_PLATFORM to the folder that you expect the platforms to be located at. I did not like this solution do to the fear that it could interfere with other applications installed on the end system.
The next solution is to take advantage of the command line parameters that a normal QT application would use. In a normal Qt application QApplication would be created in your main similar to:
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
//other code
return app.exec();
}
Well we have to create argv and argc anyway at this point so use that to our advantage.
char *argv[] = {"YourAppName","-platformpluginpath", "C:/your/path/to/dll/folder", NULL};
int argc = sizeof(argv) / sizeof(char*) - 1;
QApplication app(argc, argv);
NOTE: Even now googling for -platformpluginpath I could not find any information for it. Or information on what other command line parameters may be available to use with QT. I found it by digging into the QT source code while looking for a solution. So if anyone happens to have a link to a resource with that information it would be handy to leave a comment with it.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx#standard_search_order_for_desktop_applications
When you are running your program in Qt, it adjusts the environment variables to add some stuff on to your path.
The default "path" that your dll is aware of when it is being ran depends on the exe that loads it, and its working directory, its application directory, etc. If you test program that is loading your dll, is in the same folder as the dll, you probably just need to put qwindows.dll in "./platforms/".
You also should check into this function:
http://qt-project.org/doc/qt-4.8/qcoreapplication.html#setLibraryPaths
http://qt-project.org/doc/qt-4.8/qcoreapplication.html#libraryPaths
Hope that helps. Good luck.
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.