Howto resolve qml module not found (qml designer) - qt

As per https://doc.qt.io/qtcreator/qtquick-placeholder-data.html#creating-dummy-context I want to add a dummy context to my QT 5.15.2 project. The webpage mentioned creating a qml file with the following content:
import QtQuick 2.0
import QmlDesigner 2.0 // this is where the error is indicated: qml module not found (qml designer)
DummyContextObject {
parent: Item {
width: 640
height: 300
}
}
Apparently the QmlDesigner module is unknown. I don't know how to solve this.

The qml code model does not know anything about the existence of that type. So it is correct if it shows that to you.
In detail, that object only exists if the backend process (qmlpuppet or in documentation called emulation layer) renders stuff for the form view in the designer.
But in the current implementation, the qml code model does not know anything about added objects when the emulation layer is running.
I would create a bug report at https://bugreports.qt.io/ about that issue. So the qml code model needs to know about that type somehow.
To make sure that the feature works in the design mode please make sure you are following the help for example there is no qmldesigner 2.0 version only 1.0 exists.
Explanation in the puppet the object is registered with:
qmlRegisterType("QmlDesigner", 1, 0, "DummyContextObject");
see https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp#n184
Also, the file and folder structure is importent.

Related

QML App full screen/immersive mode on Android and iOS

I made a very simple Qt Quick Application (all using QML) and want it to appear as full screen/immersive mode on android. How can I achieve that?
You can achieve it with QML in ApplicationWindow:
ApplicationWindow {
//...
visibility: Window.FullScreen
}
Android creates an "activity" instance (android "view") before your/any Qt code runs. This view/activity decides whether the "title bar" of android is shown or not, so you will need to modify the parameters with which this view/window is created. I believe this can't be done at runtime of your app (you could make two activities and switch between them though).
Your Qt-project needs an AndroidManifest.xml to be deployed with your compiled code. If you didn't add one yourself then the default one gets pulled during deployment, but you can override it with your own file. The parameters needed to go fullscreen can be set in this file. See About the Full Screen And No Titlebar from manifest for details.

Can I globally switch to native text rendering in Qt Quick Controls 2?

I would like to use native rendering for all the text in my application. For each Text, Label, etc. element I can do this
Text {
renderType: Text.NativeRendering
}
to trigger native rendering. I can also use the software renderer for the whole application:
QQuickWindow::setSceneGraphBackend(QSGRendererInterface::Software);
However due to some bugs with the software renderer and some performance issues, I would like to avoid that.
Is there a global switch to change the render type?
Since Qt 5.7, you can change the default Qt Quick text render type, but unfortunately only at build time. In order to change the default, you would have to rebuild libQt5Quick.so with QT_QUICK_DEFAULT_TEXT_RENDER_TYPE set to NativeRendering. For more details, see https://codereview.qt-project.org/#/c/121748/ .
If you have installed Qt using an installer from qt.io, install the source packages using the maintenance tool if you already haven't done so, navigate to qtdeclarative/src/quick, run qmake with the define, and build. Something along the lines:
cd path/to/Qt/Sources/5.8/qtdeclarative/src/quick
# NOTE: make sure to run qmake from the same/correct Qt installation
path/to/Qt/5.8/<spec>/qmake "DEFINES+=QT_QUICK_DEFAULT_TEXT_RENDER_TYPE=NativeRendering"
make -jN
If you have a self-built Qt installation, invoke make clean (or if you want to save time, just delete qquicktext*.o) before make to rebuild the library.
EDIT: Since Qt 5.10, it is also possible to specify the default text render type in C++ via QQuickWindow::setTextRenderType(). Just notice to set it before loading the QML content.
The environment variable QML_DISABLE_DISTANCEFIELD controls this.
If you put
qputenv("QML_DISABLE_DISTANCEFIELD", "1");
at the beginning of your main, you will get a nice and sharp text rendering everywhere.
Source: http://www.kdab.com/~thomas/stuff/distancefield.html
Add this line first in c++ main function : QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);

Input video data from C++ to QML Video Player

I am looking for a best way to implement a video player application in QML. Almost all QML examples are reading files from filesystem or web:
MediaPlayer {
id: mediaplayer
source: "groovy_video.mp4"
}
VideoOutput {
anchors: parent.fill
source: mediaplayer
}
I want to specify my own source for MediaPlayer - a C++ QObject derived class, that has an interface similar to QIODevice. That would be perfect for my needs. I need to preload video in parts and also to cache it for later use.
Is there an easy solution for my needs?
(I am using Qt 5.2)
Generally speaking you should be able to override any URL that is loaded by QML. The Qt 4 docs are a bit more explicit about this than Qt 5:
https://doc.qt.io/qt-4.8/qdeclarativenetwork.html
But the same should be similar for Qt 5:
http://doc.qt.io/qt-5/qqmlnetworkaccessmanagerfactory.html
e.g. you should be able to use a specific url schema for a custom source magic+videos://.... for your custom source.
Worst case scenario you have to inherit (and override some methods) from QNetworkAccessManager and QNetworkReply (which inherits from QIODevice).
I have not played with this since qt4 but I assume a good starting point would be this:
http://doc.qt.io/qt-5/qtqml-networkaccessmanagerfactory-example.html
I'm a bit outdated on this kind of stuff, but hopefully this helps.

How to make Qt Creator to show pop-up documentation of my functions the same way it does for the functions from the Qt library?

When you place the mouse pointer over any Qt function/class it shows a pop-up with short description of what it does, taken from the docs in the comment above the function/class.
For my functions/classes I have documentation in the doxygen format:
/**
Returns foo
*/
QString getFoo() {
return "foo";
}
When this function is used, I want to view the same type of pop-up with my docs when the mouse pointer is over the function name.
Is it possible to do that with Qt Creator?
Unfortunately it's not possible for Qt Creator (as of the recently release 2.4) to pick up the tags on-the-fly. However, what might work is to let doxygen run, and tell it to create qch files. If you register the created qch file, you should get mouse-over and even a proper help file. See http://www.ogre3d.org/tikiwiki/Integrating+API+documentation+into+Qt+Creator+Help for how Ogre3D does it. YMMV if that's worth it for a fast-changing project. It's certainly a good idea for a (semi-)stable library.
Relevant bug report: https://bugreports.qt.io/browse/QTCREATORBUG-4557
Qt Creator requires the generated docs to have some special markers in order to retrieve the tooltip text. I couldn't find a way to insert these markers with Doxygen so I've created a simple script to do it:
https://github.com/mmmarcos/doxygen2qtcreator
It's not bulletproof but it allows us to integrate our classes and methods briefs into Qt Creator tooltips.

Adobe AIR: Controls flipped (mirrored) in certain build environments

I'm having an issue where certain controls are flipped, depending on the machine that I'm building my project on. On my development machine, when I build it, everything is okay. However, when I build it on our build server, some things are flipped. It seems to be things that are on a higher layer - for instance, options in the select control (see first image below), alerts/overlays (see second image below), etc. It's not just the text, either - the entire content is flipped, images and all.
I have verified that the code is exactly the same in both instances, so it must have something to do with settings or the flex SDK version. On my development machine, the Flex SDK version is 4.0.0.14159, and on the build server, the Flex SDK version is 4.1.0.16076. I can downgrade the SDK on the build server if needed - but could it really be an issue with the SDK? Any ideas?
Thanks!
It looks like this will be fixed in the 4.5 SDK--see SDK-26473 for workarounds.
I was able to fix the mirroring by turning off Flex 3 Compatibility Mode in the Flex compiler settings (if using mxmlc, -compatibility-version=4.0).
Your build machine must be set to a locale which uses right-to-left text, such as Hebrew or Arabic keyboard setting.
Oops - hadn't read all of dpstone's answer before I posted my comment to the question.
The answer to this problem is in the bug he linked to. You need to explicitly set the layout direction. You can do this in one of two ways.
1) in a .css file that you import into your main application file:
global
{
layoutDirection: "ltr";
}
OR
2) you can set it in a <style> tag in your main application file.
<mx:Style>
global
{
layoutDirection: "ltr";
}
</mx:Style>

Resources