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.)
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 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.
The Qt tutorial for translatable texts does not mention whether it is possible to use HTML inside of a translatable string.
However, some examples I found use it, so it seems to be possible.
However, if I so much as use "<B>text</B>" in my .ts file, Qt Linguist does not open it. It displays the error message "unexpected tag" instead.
The ts file is XML. If you want to use HTML tags you will need to escape them. For example: <source><b>text</b></source>
Note that the recommended way of managing translations in Qt is to run the lupdate tool on your source code and have Qt generate the .ts file, in which case this will be done automatically.
I can see from the documentation on https://qt-project.org/doc/qtcreator-2.6/creator-sharing-project-settings.html how to create a .pro.shared file that standardizes Editor settings.
But: is it possible to standardize Qt Creator's "Code Style" settings in a .pro.shared file, and if so, what is the syntax?
There is currently no UI way of doing that, not sure if we will add one at some point.
So you will need to do this manually: Set it up for a user, close the project to make sure the .user file is saved and copy copy the file into a .shared file. Remove everything you do not want to share (keep ProjectExplorer.Project.Updater.FileVersion!), while keeping the XML structure intact. You are a developer, I am sure you will manage:-)
Oh, make sure to use the oldest Qt Creator you want to support (IIRC this was introduced in 2.5, so going older than that won't help) to create the template. Creator will upgrade settings while reading them but it can not downgrade, so .shared files that are too new are going to be ignored.
Is there a stylesheet available for use in Qt applications (through Qt Creator) that makes your GUI use the stylesheet you see in Qt Creator itself, as well as in AutoCAD and some other applications?
What is the name of that stylesheet or where can I get it? It looks much like the Vista stylesheet though...
And whenever you set a custom stylesheet to your Qt application, will it display the same style on all platforms, or will it still display native GUI parts?
To the people that may want to find out more: The style seems to be called manhattanstyle and extends QWindowsStyle. It is not a css-stylesheet and therefore not just copy and paste to set up. It seems to have some other dependencies in the source code, so I don't know how much it will take to adapt it.
The source is found in the [qt-creator source code]/src/plugins/coreplugin/manhattanstyle.cpp
And btw: if you are running debian/ubuntu: type apt-get source qt-creator to get the source ;)
I can't say as to how you would get style sheets that match Qt Creator or AutoCAD but to answer your other question: When you apply a style sheet, it applies to the object you applied it to, and the child hierarchy of that object. Any widget not addressed by the style sheet in some way will maintain the native look and feel that matches the Style (not style sheet) chosen by Qt as most appropriate for you application based on the user's platform and desktop environment.
yes, somebody has separated it out.
see this Manhattan style