Strange //! comment syntax in Quick Controls 2.0 QML source [duplicate] - qt

This question already has an answer here:
//! [0] in Qt source code
(1 answer)
Closed 6 years ago.
While looking through Quick Controls 2.0 sources, I came upon a peculiar comment syntax that I can't seem to find in docs:
//! [property]
property: ...
...
//! [property]
for example, pairs of //! [contentItem], //! [background] could be seen in TabButton.qml.
I wonder if this is just a convention chosen by the developers to delimit regions of code, or does it indeed have some special meaning?

With Qt comments that begin with ! are parsed to generate documentation. That applies to single and multi line comments.
In this particular case however it doesn't seem to contain any actual documentation, it is used to signify the lines where individual implementation details begin and end.
You can learn more about the documentation format here.

There used to be example code snippets on the Customizing Qt Quick Controls documentation page, that were automatically extracted from our own QML code with help of those qdoc-markers.

Related

How to find the source of a recursive rearrange in QML

I updated my QML application from Qt 5.12 to Qt 5.15.
My application loads its qml sources using the following code:
auto* engine = new QQmlApplicationEngine(this);
...
engine->load(QUrl("qrc:/main.qml"));
When engine->load is called, I now get the following warning, which was not there with Qt 5.12:
Qt Quick Layouts: Detected recursive rearrange. Aborting after two
iterations.
How can I find the source of this warning so I can fix my code?
Edit:
After two downvotes, I would like to clarify the intent of my question.
I have a very large application which is loading a big tree of qml files, with main.qml being the main Window. The warning that I posted comes from the Application output pane, without any hint to a source file location that caused the warning.
I am looking for a way to find the source file location that caused this kind of warning. I believe it is reasonable to ask how to achieve that, and I believe that this is a generic problem that will come up for many people who update their qml code to Qt 5.15. It's in the nature of such a issue that a self-contained example (like asked for in the comments) cannot be provided.
It's a totally reasonable ask - the warning is ambiguous so you'd have to post the entire codebase to get a minimum viable. Afaik there is no reasonable way to locate the offending bits programmatically but look for Layout components (RowLayout, ColumnLayout, GridLayout) nested inside the same kind of Layout component; these are the usual offenders. For instance:
ColumnLayout {
ColumnLayout {
id: childColumnLayout
// this is generally the cause of your grief
// changing the the child ColumnLayout to a Column usually fixes it for me
}
}

Localization in QtQuick from top to bottom

After several weeks of on-and-off research, I still haven't found a thorough guide on how to perform translation/localization in QtQuick (as in, using the QML language, not C++ or Python).
In general, I'm asking what are the steps to properly localize a project as much in QtQuick as possible, with minimal or preferably no C++.
More specifically, there are a good number of holes I need to fill in my understanding of how QtQuick handles localization.
So far, I've:
Appended QT_TR_NOOP() to all of my translatable strings for translation at runtime
Added my file containing all strings to my .pro file using lupdate_only{SOURCES += LanguageStrings.qml}
Generated translation files using QtLinguist
However, I intend to implement an option for dynamically changing the language, and the only example I've seen regarding translation which wasn't entirely in C++ essentially created an instance of the project for each language, rather than changing the strings at runtime.
So, how do I change the language at runtime? Is there a variable I can set? Is it pulled from system locale? I haven't seen a solid answer on this.
Any ideas?
You can do this with minimal C++ (at least I think this is minimal). I've done this in the past using the locale of the system the app is installed on like this (directly in main()):
QGuiApplication app(argc, argv);
QTranslator translator;
if(translator.load(":/translations/myapp_" + QLocale::system().name())) {
app.installTranslator(&translator);
} else {
qDebug() << "Unable to load translation";
}
The translations need to be in the resource system for the above to work. You can of course trigger the above based on user input from QML (e.g. in the settings of your app) at run-time. Here is some example code to do this (https://wiki.qt.io/How_to_do_dynamic_translation_in_QML). I am not aware of a QML-only way to do this.
I tried something else which works, too. You can have your UI in a Loader Element and simply use the setSource functions of that element after the translator changed. I quickly put together a small example, which also includes an example of how to change UI elements outside the Loader, if that is needed (https://github.com/Conntac/qtExamples).

Excluding Qt structures from Project documentation in doxygen [duplicate]

This question already has answers here:
Exclude some classes from doxygen documentation
(3 answers)
Closed 4 years ago.
I'm documenting a project built in Qt using doxygen, my problem is that classes and structures from Qt such as QString is being documented.
I want to exclude all QString types from my documentation and only keep the ones i declare and implement.
I know that this should be done some way in the doxyfile, but i have no idea how to do it. Any idea??
Thanks in advance.
Use the doxygen exclude property:
http://www.doxygen.nl/manual/faq.html

Undocumented ProcessEventsFlag enums in QT

I noticed that modal dialogs on QT uses a local QEventLoop with the ProcessEventFlags set as "DialogExec"
eventLoop.exec(QEventLoop::DialogExec);
The QT assistant has no information on what this enum means. There is another one called EventLoopExec. Anyone has any idea what they actually mean and why aren't they documented?
Thanks
I did some poking around and this is what I found:
This enum is intentionally omitted from the documentation, along with several other QEventLoop::ProcessEventsFlag enum values (X11ExcludeTimers, ExcludeUserInput, WaitForMore, EventLoopExec) as there is an \omitvalue in front of each one in the comments that generate the docs.
There is only one place in all of Qt that actually uses it, in qeventdispatcher_mac.mm in which it appears to be some kind of mac-specific optimization according to the in-line comments
The intentional omission of these values from the docs leads me to conclude that they're for internal Qt use only, and that you shouldn't need to use them or worry about them.

Flex 3 + Flash Player 10 FileReference save function [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
help, losing extension when use FileReference download
Hi!
I'm having an issue that looks common when using the FileReference class in FP10 when saving a file.
The whole thing works fine as long as I don't change the default filename. If I do, then I loose the extension of the file... which is annoying >_<
I haven't found any "acceptable" workaround, but the posts I've seen are from a couple of months already. So I'm inquiring hoping that something's been done regarding this issue since then =)
Regards,
BS_C3
The only thing i am aware of that you can do is: After succesfull saving check the filename and display a warning if the user used the wrong/no extension.

Resources