qtquick2

QML binding to an array element

空扰寡人 提交于 2019-12-19 01:24:25
问题 I have a width property on a QML Rectangle that is set based on another Rectangle with an id of mainwindow and one of the array properties of mainwindow : width: mainwindow.width/mainwindow.numColsPerRow[positionRow] This works at the time my rectangle is setup; that is, the element inside the array numColsPerRow is correctly involved. However, after this Rectangle is setup, if I change the values inside numColsPerRow the width of this Rectangle does not have any effect. Does QML not allow

Populate GridLayout with Repeater

纵然是瞬间 提交于 2019-12-18 13:35:15
问题 I try to add cells to my GridLayout by using a Repeater . My data is stored in a model and containing two properties per element: Title Value My goal is to get a GridLayout containing the Title in first cell and the Value in the second cell of each row. GridLayout { id: someId columns: 2 rowSpacing: 5 columnSpacing: 5 anchors.margins: 5 anchors.left: parent.left anchors.right: parent.right Repeater { model: myModel Label { text: modelData.title } TextArea { text: modelData.value } } } But QML

How to apply opacity mask to a QML item?

守給你的承諾、 提交于 2019-12-18 06:18:16
问题 The look and feel I'm trying to go for is to have a solid color button, and text on it like "Hello World" where the text is completely transparent, and the background shows through the button. In other words, having text as a transparency mask on a button element. 回答1: Here is one way to do it: // TB.qml MouseArea { width: txt.contentWidth + 20 height: txt.contentHeight + 10 property alias text: txt.text property alias color: sh.color ShaderEffect { id: sh anchors.fill: parent property color

How to apply opacity mask to a QML item?

谁都会走 提交于 2019-12-18 06:17:09
问题 The look and feel I'm trying to go for is to have a solid color button, and text on it like "Hello World" where the text is completely transparent, and the background shows through the button. In other words, having text as a transparency mask on a button element. 回答1: Here is one way to do it: // TB.qml MouseArea { width: txt.contentWidth + 20 height: txt.contentHeight + 10 property alias text: txt.text property alias color: sh.color ShaderEffect { id: sh anchors.fill: parent property color

QML Form layout (GridLayout) troubles

那年仲夏 提交于 2019-12-18 05:03:58
问题 I am trying now to convert my app UI from C++ to QML. At some step I need a login window so I created it in QML with code below: Window { id: loginWindow property string username: login.text; property string password: password.text; property bool issave: savePassword.checked; flags: Qt.Dialog modality: Qt.WindowModal width: 400 height: 160 minimumHeight: 160 minimumWidth: 400 title: "Login to program" GridLayout { columns: 2 anchors.fill: parent anchors.margins: 10 rowSpacing: 10

Remove rows from QAbstractListModel

戏子无情 提交于 2019-12-18 04:55:10
问题 I have a custom model which derives from QAbstractListModel which is exposed to QML. I need to support operations to add new items and remove existing items. While insertion operation works without any problems, removal operation causes the application to crash while calling endRemoveRows() function. void GPageModel::addNewPage() { if(m_pageList.count()<9) { beginInsertRows(QModelIndex(),rowCount(),rowCount()); GPage * page = new GPage(); QQmlEngine::setObjectOwnership(page,QQmlEngine:

Load qmldir from QRC file

巧了我就是萌 提交于 2019-12-18 02:49:43
问题 I'm trying to use the QML-material library in a Qt Quick Application. But when I try to use the import code it says module "Material" is not installed` import Material 0.1 I did also try this but that seems not to work: import "modules/Material" as Material qml.qrc looks like this, all qmldir files are listed: <RCC> <qresource prefix="/"> <file>main.qml</file> <file>modules/Material/qmldir</file> <file>modules/Material/Extras/qmldir</file> <file>modules/Material/ListItems/qmldir</file> <file

Image rounded corners in QML

血红的双手。 提交于 2019-12-17 18:28:24
问题 To my surprise, the Image component has no radius property. I tried emulating the rounded corners by putting the image in a rounded Rectangle , but it does not clip the corners. Rectangle { anchors.right: rectContentBg.left anchors.top: rectContentBg.top anchors.margins: 8 radius: 8 width: 64 height: 64 Image { id: imgAuthor opacity: 1 smooth: false anchors.fill: parent source: "qrc:/res/sample_avatar.jpg" } } How can I create an image with rounded corners properly? 回答1: A built-in official

How do I apply the style to a TextField in QML? It seems “style” attribute isn't available

╄→гoц情女王★ 提交于 2019-12-17 16:47:14
问题 I am trying to apply some styles to a new qt 5.7 application I am working on and the following is not working at all. It gives the error: qrc:/SignInView.qml:67 Cannot assign to non-existent property "style" And I can't edit it in design mode for the same reasons. import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.1 import QtQuick.Controls.Styles 1.4 Page { id: page1 ColumnLayout { id: columnLayout1 height: 100 anchors.right: parent.right anchors.left: parent.left anchors

Exe file does not run without QtCreator

£可爱£侵袭症+ 提交于 2019-12-17 10:49:37
问题 I installed Qt 5.0.1 for Windows 32-bit (MinGW 4.7, 823 MB) Then I created simple Quick 2 application and compiled it. Application is located in the its folder, and apllication run from QtCreator. And I want to run this exe file without QtCreator. To do this, I copy the files from the C:\Qt\Qt5.0.1\5.0.1\mingw47_32\bin : Qt5Core.dll icuin49.dll libgcc_s_sjlj-1.dll libwinpthread-1.dll libGLESv2.dll libstdc++-6.dll qminimal.dll Qt5Gui.dll Qt5Network.dll Qt5Qml.dll Qt5Quick.dll Qt5V8.dll