QML Extension Plugin - qt

How do we use the dll file created by QML Extension Plugins?
The link regarding dll file creation, doesn't give enough information about how do we exactly use the dll file in other projects (Qt Quick applications).
A simple example on this with step by step explaination would be helpful.

Related

VS 2019 extension to run resource generator on project load

We want to exclude the designer.cs files, generated from RESX files, from our repositories.
To achieve this, we need to make VS run the resource generator at project load (because the resource generation tool only runs when a RESX file is changed).
This triggers two questions:
Is there already an extension which does this (can't find one).
If not, which SDK class/event can I hook into so I can run the resource generator when a Project loads? (I appreciate I'm then going to have to iterate through the files in the project).
Is there already an extension which does this (can't find one)
We can search extensions in VS marketplace. Most of them for currently are for free. But it seems there's no such extension there to do behavior as you expected.
If not, which SDK class/event can I hook into so I can run the
resource generator when a Project loads? (I appreciate I'm then going
to have to iterate through the files in the project).
Maybe the event that you're looking for is IvsSolutionEvents3. The IVsSolutionEvents3.OnAfterLoadProject or IVsSolutionEvents3.OnAfterOpenProject method can help.
In addition: Topic about how to detect and manage solution and project loading see here.

Path to the project current dir in qt

I want to get a path to the project directory in Qt and reference the other files of my project relative to it. I know this issue have been already discussed here
Get current working directory in a Qt application
and here
How to get current working directory path of a Qt application?
but the answer is still unknown. In case it's impossible to get such a path then what is the approach of navigation among files of the Qt project.
Based on your comment, you are trying to:
Access some images which are being used in my program. I could of course put them into build target directory, but it becomes uncomfortable to pass my code to others.
The approach to store resource files in the project source directory and rely on such structure at runtime is not a greatest idea. I can't imagine the situation when mixing the concepts of initially decoupled source and build directories could be useful, correct me if I'm wrong.
So, according to your needs:
The most simple and plain way is to use the Qt resource system. The resource files are simply embedded into the executable, so there will be no need to access the file system.
Another way is the automatic deployment of the needed files. This answer describes the way to copy your files to the target directory using qmake.

why plugins in Qt have .dll and .lib files?

Plugins as I know are loaded at run time so they don't need .lib file and a .dll file is adequate to load them at run time. But when you create a plugin in Qt and compile it in, say Windows , you get a .dll file and a .lib file and some other files. The most amazing part of the story is that you don't need to link it to your program if want to use the plugin. So why is it necessary?
It's the standard qmake way of building a shared library, which automatically outputs the import library as well.
Just because it's a plugin and can load it as a plugin, should not mean you can't use it as a library, because a dll is still a library, and plugin-related functions might be useful if exposed through the usual shared library interface.

Compiled distribution of Qt application for windows

I was successfully able to compile and run my Qt application. However, when I move the .exe file outside its original path, I found out that I have to manually copy the Qt DLLs (e.g. mingw10.dll, qtcore4.dll). Is there any dynamic way to link these libraries with my application?
I think you mean you want to "statically" link these libraries with your application.
Basically this means that everything will be rolled inside your exe, and you will have no need of those dlls anymore.
There are advantages to to static linking, but there are also disadvantages as well. You should be absolutely sure that this is what you want to do before you go this way.
Check out this link which explains the difference in depth Dynamic Linking vs Static Linking
As for your specific issue, if you are sure you want to use static linking you will have to change your Qt setup to be built statically. By default the Qt distribution is setup to use dynamic linking. There is a handy guide for that here.
Basically when you setup the build you have to run "configure -static" to change all the project settings to use static linking instead of dynamic linking. And then build Qt over again.
You should also verify your Qt license. If you are using the Qt LGPL license and you want to to link statically you will have to include all your object files (.o and .obj) as Mihai Limbășan wisely explained in his comment. If you have bought and paid for Qt, then you have no problem.
If the DLLs are on the PATH for the application, then they will be found and work. So, you could add where your Qt binaries/dlls are into the %PATH% environment variable. If you're going to create an installer for your application, you'll need to either package these libraries in so they're in the bin directory - or you'll have to expect every user to install and possibly compile Qt themselves (hint: go with the first option. :) )

Qt Creator - how to see the code of the designer?

I'm using Qt Creator.
I'm using the signals and slots editor, and I want to see the code it generates.
How can I see the code?
Thanks!
Let's say you have in Qt Creator a form file called widget.ui.
Once you've compiled your project, you'll find in your project folder a filed called ui_widget.h.
If you open it, you'll see the code generated by the uic tool.
when you use qt creater, this one is going to create a file with the name of your project, in my case it is called "build-prueba-Desktop_Qt_5_7_0_GCC_64bit-Debug", then in that file you have to look for a file with the "ui_" prefix, into that, you have the code you need

Resources