qml

Landscape mode in Qt-Android application

梦想与她 提交于 2020-01-03 04:42:07
问题 I created a Qt/QML application and ported the application to Android. Now I'm able to run the application on the Android device. I want to fix the orientation mode to Landscape. I manually edited the AndroidManifest.xml and set the android:screenOrientation="unspecified" to android:screenOrientation="sensorLandscape" <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name=

Get user input from qml to c++

…衆ロ難τιáo~ 提交于 2020-01-03 03:28:08
问题 I'm trying to get user input from qml TextField to c++ , but it only works if text property value is hardcoded (const value) . c++ QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); QObject *rootObject = engine.rootObjects().first(); QObject *serverField1 = rootObject->findChild<QObject*>("serverField1"); qDebug() << serverField1->property("text"); //Here I expect to get user input Qml ApplicationWindow { id: applicationWindow visible: true width: 300 height:

QScrollArea in Qml: Flickable + QQuickPaintedItem

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 10:33:39
问题 I'm trying to realize something similiar to QScrollArea (in widgets world) with the help of Qml. I decided to probe Flickable plus QQuickPaintedItem based item (named Drawer in my case): Flickable { ... onContentXChanged(): { drawer.update() } Drawer { id: drawer ... } Drawer's render target is set to FrameBufferObject . Its paint function looks like this: void Drawer::paint(QPainter *painter) { // Some function to compute rect which is needed to be redrawn QRect updateRect =

QScrollArea in Qml: Flickable + QQuickPaintedItem

☆樱花仙子☆ 提交于 2020-01-02 10:33:29
问题 I'm trying to realize something similiar to QScrollArea (in widgets world) with the help of Qml. I decided to probe Flickable plus QQuickPaintedItem based item (named Drawer in my case): Flickable { ... onContentXChanged(): { drawer.update() } Drawer { id: drawer ... } Drawer's render target is set to FrameBufferObject . Its paint function looks like this: void Drawer::paint(QPainter *painter) { // Some function to compute rect which is needed to be redrawn QRect updateRect =

Qt QML ComboBox override wheel events

强颜欢笑 提交于 2020-01-02 08:51:33
问题 Is there any way to override ComboBox MouseArea to ignore wheel event instead of changing current index? ComboBox itself has no option to change wheel focus behaviour. So far I've tried to override onWheel from CB MouseArea with code like this: ComboBox { Component.onCompleted: { for (var i = 0; i < combobox_ctrl.children.length; ++i) { console.log(combobox_ctrl.children[i]) console.log(combobox_ctrl.children[i].hasOwnProperty('onWheel')) if (combobox_ctrl.children[i].hasOwnProperty('onWheel'

Text2DEntity renders opaque and hides other entities behind it

一个人想着一个人 提交于 2020-01-02 07:19:30
问题 I draw some 2d text entities in a Qt3D QML scene but some of the texts always render opaque , i.e hide the contents behind them. When looking at the scene from behind ( changing the position of the camera to Qt.vector3d(0,0,-40) ) all texts render OK. The following image shows the wrong behaviour, I would expect the text "AAARGH" not to be rendered on a white background, but the green text shining through. Platform is Windows 64-bit, Qt5.13.0, and Visual Studio 2019. See the following small

QML not using Thin font weight

戏子无情 提交于 2020-01-02 07:04:42
问题 I have a QML app using the freely-available Encode Sans font, which comes in 9 weights that match Qt 5.6's font weights. I have added all .ttf to my project, and am using a FontLoader to load them. Everything works perfectly, except for the Thin weight of the font. In addition to the code below I have tried providing a unique id on the FontLoader for Thin, to ensure that the family name is the same (it is). How can I debug this problem and get Thin working? ### main.qml FontLoader { source:

How to animate and propertly intepolate a QML rotation transform in 3D

こ雲淡風輕ζ 提交于 2020-01-02 06:38:32
问题 This code sample here: import QtQuick 2.0 Item { width: 200; height: 200 Rectangle { width: 100; height: 100 anchors.centerIn: parent color: "#00FF00" Rectangle { color: "#FF0000" width: 10; height: 10 anchors.top: parent.top anchors.right: parent.right } } } Will produce this output: Now I want to apply a 3D rotation from the center of this green rectangle. First, I want to rotate on X by -45 degrees (bowing down), then on Y by -60 degrees (turning left). I used the following c++ code

Better way to reparent visual items in QML

末鹿安然 提交于 2020-01-02 05:46:07
问题 It would seem that in the design of QML user reparent was not really "envisioned", because even though it is possible, it involves creating and changing states, which is just not convenient to add to each and every item. import QtQuick 1.0 Item { width: 200; height: 100 Rectangle { id: redRect width: 100; height: 100 color: "red" } Rectangle { id: blueRect x: redRect.width width: 50; height: 50 color: "blue" states: State { name: "reparented" ParentChange { target: blueRect; parent: redRect;

Q_PROPERTY NOTIFY signal and its argument

99封情书 提交于 2020-01-02 04:44:06
问题 I have the habit of writing my "propertyChanged" signal s with an argument, such that the receiving end doesn't need to call the Q_PROPERTY 's READ function explicitly. I do this out of clarity and the assumption that in a QML data binding situation, no "expensive" call to the getter needs to be done to actually fetch the value, as it's already passed to QML as a signal argument. My colleagues disagreed and said it was against "QML style", to which I responded the documentation clearly states