How can I add a resource to .qmlproject - qt-creator

I have created a new qmlproject using New File or Project… / Applications / Qt Quick 2 UI with Controls. I'd like to add resources (such as image files and fonts) to the project.
When I rightclick on the project, the entry Add Existing Files… is greyed out.
When I choose Add New… / Qt / Qt Resource file, Qt Creator creates a new resource file, but then pops up an error message that the file could not be added to the project.
When I drag an existing file from Finder to the project, Qt Creator open the file in a hex editor, but does not add it to the project.
I could not find any documentation on this, so this is why I would like to know: what is the standard way for adding a resource to a .qmlproject?
I'm using the version of Qt Creator bundled with Qt 5.2.0 beta 1

I don't think you can.
The type of project wizard you chose is documented here:
Qt Quick UI (in the Other Project category) creates a Qt Quick UI project with a single QML file that contains the main view. You can review Qt Quick UI projects in a preview tool and you need not build them. They do not contain any C++ code.
Qt Quick Controls UI is like Qt Quick UI, but using Qt Quick Controls.
The part in bold is key here, because .qrc files must be compiled into the application's executable, which can't happen when you don't have any C++ files to compile. Even if you had external binary resources, there's no QML API to register them as far as I'm aware; only C++.
Newer versions of Creator seem to recommend against it:
Creates a Qt Quick 2 UI project using Qt Quick Controls with a QML entry point. To use it, you need to have a QML runtime environment such as qmlscene set up. Consider using a Qt Quick Controls Application project instead.
I wouldn't recommend using the .qmlproject format. From memory, the last time I tried to deploy such a project to e.g. an Android device, it didn't work. You're better off using the "Qt Quick Application"/"Qt Quick Controls Application" project.

Related

Qt - Resources are always lost in exe built with Visual Studio

I'm trying to build a demo application with Qt in Visual Studio 2019. I used the Qt VS Tools in the Visual Studio IDE, and the Qt Designer to create my user interface. I also used the Qt SVG module in order to use SVG images for my user interface.
I achieved a working project, which works pretty well in debug and release mode, as long as I run it from the Visual Studio IDE. Now I would like to distribute it as an independent .exe file. For that I tried to create a zipped archive containing the .exe itself, the required Qt DLLs, and of course the resources the interface requires.
The compiled .exe can be executed in its own dir without problems, however none of the images I added in the resources are visible. I tried several ways to resolve the issue, and read many tutorials explaining how to use and/or embed Qt resources in the exe file. None of them worked for me.
I already tried to:
Simply copy the images in the .exe dir, keeping their dir hierarchy or not, but only the .png and .jpg images were visible, all the SVG were lost.
Compile a Qt resource file (.rcc) using the Qt rcc.exe tool, and add it to the Visual Studio resources, not worked.
Generate a .pro file using the "Create basic .pro file..." menu item (which also generated a .pri file) and add the following line, without success:
RESOURCES += MyResName.qrc
Adding the below lines in various location of my source code (main form constructor, main() function, ...). Nothing worked:
QResource::registerResource("MyResName.rcc");
...
Q_INIT_RESOURCE(MyResName)
Playing around and mixing the above mentioned ideas, nothing worked.
So can someone give me an as simple as possible explanation about how to correctly build an .exe file with its required resources, which may work in an independent way, using Qt and Visual Studio 2019, in order to distribute it, respecting the following constraints:
The project is a C++ project developed with Qt and Visual Studio 2019.
The project uses Qt, has a .ui file built with Qt Designer, which embeds several SVG and/or PNG/JPG images, and in which these images are visible in design time and if the exe is run from the IDE.
The project uses a .qrc file pointing the images, SVG or not, required for the application.
The images were added to UI components through the styleSheet property, like that:
image: url(resources/images/im-dropbox.svg) center center;
Other resources files, like .pro, .pri, .rcc, ... may be generated without problems. The required resources are well embedded in the generated files (verified).
Please help me, because this situation gives me headache.
I'll try to cover all the issues i see, in the order i see them.
First you don't use the files from resources, the Qt resource file paths start with :/ for example to set an icon from resources (in C++ code) you will do it like:
a.setWindowIcon(QIcon(":/images/window_title_ico.png"));
Now, to use resources directly from Qt Designer, you'll need to add your .qrc file for each ui file (click on that "edit" icon and then "Open resource file") after that you can set the icons from resources, see the print screen (Qt designer started from VS)
Note: you can double check the generated .ui file (it's an xml file) to see if the icon paths start with :/ then you know you have done it right. //in the .ui file you'll see something like:
<pixmap resource="resources/resources.qrc">:/images/acceleration.svg</pixmap>
//notice the relative path to the .qrc file and the .svg file path starts with :/
And lastly to display .svg on deployment, i noticed that you need to deploy the Qt5Svg.dll too (the one from the: PATH_2_QT\5.XX.X\msvcXXX_XX\bin) deploying only imageformats\qsvg.dll is not enough.
Hope this help to clear things a bit!

How to manually set the GUID for a VB6 Activex control

Recently we have an issue where we have to modify an ActiveX control which is developed long back. Problem is, we lost the source code, but we found another version of the same control with a different GUID.
The requirement is to keep the old GUID as other products are using the same control. So we want to replace the new control GUID with old one.
Is it possible? If so please let me know how can I change the GUID of the Active X control in VB6.
You don't manually put the interface & class GUIDs into your application, but in your project settings you need to enable "Binary Compatibility" pointing to a DLL that has the interface & class GUIDs that you want to have your project use.
From the Visual Basic 6.0 Project Documentation Component Tools Guide, "Providing a Reference Point for Binary Version Compatibility":
To specify a reference version of the component type library
Open the project.
From the Project menu, choose Project Properties to open the Project Properties dialog box, and select the Component tab.
Click Binary Compatibility to lock down the class IDs in the project.
Note As explained in "Project Compatibility: Avoiding MISSING References," the Project Compatibility setting actually has nothing to do with the Version Compatibility feature.
Update the box at the bottom of the Version Compatibility frame with the full path and name of the most recent version of your component.
Whenever you make a new executable from your component project, Visual Basic compares the new interfaces of your classes to the ones described in the file you have specified. Visual Basic updates the type library version number according to the level of compatibility between the interfaces.
For more information, be sure to read through all the sections in the "Version Compatibility in ActiveX Components" portion of the documentation.

Cannot find and create Qt Quick UI Project

I'm new to Qt Creator and reading the book Qt 5 Cadaques. It told me to create a Qt Quick UI Project which is in the Other Project category in the New Project window. However, I cannot find anything like that. Did I miss something while installing the IDE? Here is the screenshot:
It is under Applications > Qt Quick Application > Qt Quick Controls X.X.
Pick a Qt Quick project, and like it says in the description of the one with Qt Quick Controls, it creates a .ui.qml file.
Hope that helps.

ActiveX Control Versioning VB 6.0

I have OCX created using VB 6.0. And this OCX has custom activex controls in it. The custom controls are used in my application. I have installed my application in a system in which I have registered mu first application.
My second application needs the custom controls which are available in my OCX , few enhancements in previous controls and new custom controls.
For this purpose I have created new OCX with previous controls and new control added. In this case in future if I need different controls I need to create more OCX files. This is difficult to maintain different OCX.
If I add new functionalities in the existing OCX and register in the system, already existing application couldn't able to find the previous version of activex control.
How to add new features in already existing ocx with out affecting the applications already using these controls?
Thanks
Publishing a component with "Binary Compatibility" allows this (with several caveats involving what you can safely change) by examining the existing version of the activex control and then re-using IDs from the type library in the new version at compile time.
See here for an explanation: http://wynport.wynsys.net/Visual_Basic_Binary_Compatibility.htm which includes a list of what incremental changes you can make.
When you compile your project, Visual Basic only creates new Class and Interface IDs when necessary. It preserves the class and interface IDs from the previous version(s) so that programs compiled using an earlier version will continue to work. If you are making a change that will result in an incompatible version, Visual Basic will warn you. If you want to maintain compatibility with older, released versions of an ActiveX component.
Ref: http://support.microsoft.com/kb/161137
To make your control binary compatible,
Open the properties dialog of project
Select Component tab
Select Binary Compatibility radio button
Browse your existing control which you have compiled
Click OK button and recompile your project

VB6 executable icons

I have quite a large VB6 project, with many forms, classes, modules and user controls.
When I create a shortcut to the compiled executable and choose "change icon" for the shortcut there are multiple icons that I can select from. This indicates that there are multiple icon resources being compiled into the executable. The first icon is the "normal" application icon which seems to be controlled by setting the icon form in the MAKE tab of the project settings. That is fine and works as expected.
The problem I have is that I just cannot find out where the other icons that are being compiled into the executable are coming from. Is there a way I can take a VB6 project or a Complied executable and find out where in the project the icons resources are being set?
I've checked all the forms and a bunch of the image lists and none seem to be the icons in question.
Any ideas?
This link talks about using the VB6 add-in manager to use an add-in called the VB6 Resource Editor. Sounds like a good place to check for more resources.
The problem I have is that I just
cannot find out where the other icons
that are being compiled into the
executable are coming from.
I believe this is a misapprehension.
The default set of alternate icons for a shortcut are held within Shell32.dll.

Resources