qtquick2

Reading QML object (CheckBox) property in a loop in C++: always the same value

孤人 提交于 2021-01-28 20:46:06
问题 I made a simple code to read the value of a checkbox from my QML in a C++ loop. However, I always get "unchecked" value, even after I toggle the checkbox with the mouse. QML: CheckBox { objectName: "simulatorCheckbox" text: "text" } C++: QObject *rootObject = engine.rootObjects().first(); QObject *simulatorCheckboxQ = rootObject->findChild<QObject*>("simulatorCheckbox"); if (!simulatorCheckboxQ) { std::cout << "simulatorCheckboxQ not found" << std::endl; std::exit(1); } auto consume = [

Is there a way to stop Qt rendering temporarily?

∥☆過路亽.° 提交于 2021-01-28 05:52:57
问题 I'm developing a qml UI using Qt Quick 2D Renderer on an ARM embedded device which runs linux. The device has a LCD screen and some standby mode when it is inactive. For some reasons (network needs to stay active), suspend to RAM is not an option. However, to lower the power consumption in standby mode it would be good to stop the UI rendering. Can this be achieved with some Qt API? 回答1: Connect directly ( Qt::DirectConnection ) to the QQuickWindow::beforeRendering() signal. That will be in

How to enable TextField selection handlers with QtVirtualKeyboard on a QQuickWidget?

坚强是说给别人听的谎言 提交于 2021-01-28 05:07:30
问题 I am integrating QtVirtualKeyboard in my QML app and this causes selection handlers to appear in text fields when some text is selected as shown below. However the handlers are not draggable if I integrate my QML app using a QQuickWidget. Instead it prints out an error: QMetaObject::invokeMethod: No such method QQuickWidget::inputMethodQuery(Qt::InputMethodQuery,QVariant) Here is a minimal reproducible example: main.cpp: #include <QApplication> #include <QQuickWidget> int main(int argc, char

GridLayout Arrangement

社会主义新天地 提交于 2021-01-28 02:25:43
问题 Following is my main.qml : Window { id: window visible: true width: 800 height: 480 title: qsTr("Hello World") ListModel { id: _listModel ListElement { textData: "E1" isEnabled: false } ListElement { textData: "E2" isEnabled: false } ListElement { textData: "E3" isEnabled: false } ListElement { textData: "E4" isEnabled: false } ListElement { textData: "E5" isEnabled: false } ListElement { textData: "E6" isEnabled: false } } ListView { id: _listview model: _listModel width: 100 height: parent

How to center dialog on screen in QtQuick Controls 2?

此生再无相见时 提交于 2021-01-02 05:31:35
问题 All my dialogs appear on the top left corner of screen instead of the center. What is the best way to let the dialogs be placed automatically correct? import QtQuick 2.7 import QtQuick.Controls 2.2 ApplicationWindow { id: mainWindow visible: true width: 640 height: 480 title: qsTr("Hello World") Component.onCompleted: { showMessageBox('Hey this actually works!'); } function showMessageBox(message) { var component = Qt.createComponent("MessageDialog.qml") if(component.status == Component.Ready

How to change the font color of a MenuBar?

落爺英雄遲暮 提交于 2020-12-01 11:00:18
问题 How can I change the text color of the menu items of a QML MenuBar ? import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Controls.Styles 1.3 as QtQuickControlStyle ApplicationWindow { title: qsTr("Test") width: 640 height: 480 visible: true property color menuBackgroundColor: "#3C3C3C" property color menuBorderColor: "#282828" menuBar: MenuBar { style: QtQuickControlStyle.MenuBarStyle { padding { left: 8 right: 8 top: 3 bottom: 3

How to change the font color of a MenuBar?

允我心安 提交于 2020-12-01 10:57:43
问题 How can I change the text color of the menu items of a QML MenuBar ? import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Controls.Styles 1.3 as QtQuickControlStyle ApplicationWindow { title: qsTr("Test") width: 640 height: 480 visible: true property color menuBackgroundColor: "#3C3C3C" property color menuBorderColor: "#282828" menuBar: MenuBar { style: QtQuickControlStyle.MenuBarStyle { padding { left: 8 right: 8 top: 3 bottom: 3

How to change the font color of a MenuBar?

旧巷老猫 提交于 2020-12-01 10:57:19
问题 How can I change the text color of the menu items of a QML MenuBar ? import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.2 import QtQuick.Dialogs 1.2 import QtQuick.Controls.Styles 1.3 as QtQuickControlStyle ApplicationWindow { title: qsTr("Test") width: 640 height: 480 visible: true property color menuBackgroundColor: "#3C3C3C" property color menuBorderColor: "#282828" menuBar: MenuBar { style: QtQuickControlStyle.MenuBarStyle { padding { left: 8 right: 8 top: 3 bottom: 3