I would like to display .qhc files into my QML/QtQuick application, does anyone tried to do that?
I know that I can use QHelpEngine on the C++ part, but I would like to use qhc files directly on QML.
Related
I've been some reading/watching some tutorials here and there about qt quick and qml from last few days. But the user interface of qt creator, the boilerplate that it produces on a new qt quick project in each of the tutorial had been different. there's so much confusion.
I want to make a simple Hello World Qt Quick project, I followed this book from packt. (It has changed from the last time I saw it, but still doesn't work)
I added some a UI file, which added *.ui.qml and *form.qml files. Now if I edit .ui.qml in design, No change is reflected on any other file, but if I open some other file in design, it prompts me to use the .ui.qml file instead. The examples give an error "No Cmake config found". I'm using Qt6.2 on Arch/wayland, downloaded via installer.
How is it supposed to work? I have read this answer, and few others but I'm still confused.
Could you link to a proper tutorial, or a simple example?
The best way to think about it is that *.ui.qml should be used for UI elements and their settings. They should be about the structure, layout and styling of your UI. Doing that also happens to make the files presentable and editable in Creator's Design Mode since it simplifies the structure of the QML to the point where it can reliable present it and modify it.
*.qml files on the other shouldn't have UI elements and should instead primarily contain functions, properties and signal handers.
This pattern is sometimes referred to as "code behind". It sort of follows the same philosophy with HTML and CSS. Modern HTML documents primarily represent the structure of a page while CSS is placed in separate files to govern how they should be styled.
In this case *.ui.qml files contain the structure and styling while *.qml files containing the behavior. Creator will create a pair of them while adding a QML UI resource to your project where the .qml file inherits from the .ui.qml file.
Other than this inheritance and to encourage the code behind pattern, there's no real difference between a .qml and .ui.qml file. Creator will also try to steer you to the .ui.qml version of the pair when you go into designer to help encourage this pattern.
I will note that Qt violates this pattern a bunch all over their documentation and examples....
I recently started playing with Qt and PyQt, then I learned about Qt Designer and the .ui files they generate in xml format.
I was wondering if there is a resource website for downloading the template .ui files? That would make life much easier to start with.
As i know, it's not such practice in Qt to make template .ui files and then reuse them. If you want to reuse some ready UI components you can make Qt Designer Plugin and then use it. See documentation: Adding Qt Designer Plugins
There's no point to template .ui files because the only truly reusable element in them is styling. Layouts etc. are very application-specific. Certainly Qt style .css/.qss templates make sense. If any exist, you will find them with Google.
I am using qt linguist and qt 5.2. I have a problem that when I add something to .ui files I can see it after lupdate in ts file but when I change name of this button dynamically in my code like:
ui->label->setText(tr("foo"));
I can't see it in ts file, is it possible to make translation in that case? How I can do this?
Basically, tr() can be detected anywhere in the codes.For ui files, linguist would detect the changes immediately, however in codes I encounterd the same problem.
Based on my experience, try to reBuilt/qmake it.
(I am using Qt4.8 & 5.1.)
I want to create a qt designer plugin that behaves like the builtin QTreeWidget but i cant find the source code used to create any of the built in widgets. Help will be appreciated.
In my Qt installation (4.7.1), the designer plugin source code can be found in
<QTDIR>/tools/designer/src/plugins
Qt Creator give the possibility to attach some resource to the project.
I created in the project directory a folder called: Images. inside i have the file splash1.jpg
I created then the Resources file and attached the file as shown in the following figure:
Which is now the correct way to access from code such a file?
I tryed
QPixmap pixmap( "Images/splash1.jpg" );
QPixmap pixmap( "./Images/splash1.jpg" );
but none of them worked.
if i put just ./Images/splash1.jpg work at least if i compile by hand with qmake and make because has the correct path at runtime but no way to make it work within qt creator
Any idea??
Cheers,
Qt5 resources explains all you need. You have to put the colon before the path in the source tree. You also have placed a prefix, so :/Images/Images/splash1.jpg. This will give you a path.
If you need a URL, then use the qrc: scheme.
The correct way to load with Qt resources is: :/Images/Images/splash1.jpg.
What you could also do, is assign an alias to the resource. This way you don't need the .jpg: :/Images/splash
You can use ":/prefix/name of your image".