qml

QML ScrollView with ColumnLayout

可紊 提交于 2020-01-11 05:13:09
问题 I am trying to create a scroll view around a ColumnLayout, unfortunately my current code doesn't work. I know about ListView, but in my case I need to create scrollable Layout, because it will contain heterogeneous elements. ApplicationWindow { id: mainwindow title: qsTr("Hello World") width: 300 height: 300 visible: true ScrollView { anchors.fill: parent ColumnLayout { width: mainwindow.width Image { anchors.bottomMargin: 10 source: "img/button.jpg" width: parent.width height: 400 } Image {

How to send signals between tabs of TabView (Qt5)

回眸只為那壹抹淺笑 提交于 2020-01-11 04:05:15
问题 I have TabView with two tabs. Each tab has Item element (which contains other stuff). I need to send signal from one tab and to catch (to handle) it in other tab. If I try to send signal from one Tab (Item) to other - it doesn't work, without showing of any errors. I found a way to send signal out from tab to TabView scope using Connections as written here (http://qt-project.org/doc/qt-5/qml-qtquick-loader.html). declare in the first tab signal: signal message() Make a call in this tab (in

Using arbitrary QML items as cached image source

谁说我不能喝 提交于 2020-01-11 03:33:33
问题 EDIT: The original question is still contained below, but I decided to re-title to a form that will be more useful to developers in a variety of cases, some of which described in my answer below, as the solution to the original problem turned out to provide a much wider area of application. I have a set of greyscale icons for an application, and a requirement that the icon color can be changed by the user. So, the obvious solution is to use the stock Colorize element from QtGraphicalEffects .

How to access Items stored in a QAbstractListmodel in QML(by delegates) otherwise than using item roles?

独自空忆成欢 提交于 2020-01-10 05:09:28
问题 I just want to display elements from list using QML, but not using item roles. For ex. I want to call a method getName() that returns the name of the item to be displayed. Is it possible? I didn't find nothing clear reffering to this. 回答1: You can use one special role to return the whole item as you can see below: template<typename T> class List : public QAbstractListModel { public: explicit List(const QString &itemRoleName, QObject *parent = 0) : QAbstractListModel(parent) { QHash<int,

Load a qml component from another qml file dynamically and access that component's qml type properties

巧了我就是萌 提交于 2020-01-07 05:28:07
问题 I looked into other questions regarding this topic in StackOverflow but it did not help me. I am new to QML/Javascript and I went through QML docs regarding this question but it did not help. Below is one file 'SmallWindow.qml' Item { ... property var statusColour: calStatusColour(() property Component devViewNameComponent: devNameComp function calStatusColour() { var color = "black" //Here, colour will be changed based on some status. } Row { Component{ id:devNameComp Rectangle { id

call qmlRegisterType() in the registered class itself

扶醉桌前 提交于 2020-01-07 03:00:30
问题 In my program I have quite a lot of QObject subclasses which are instantiated in QML. Each time I add/remove a new class, I need to add/remove the corresponding call of qmlRegisterType() in main.cpp. I wonder if I can put the call in the code of the registered class itself. This makes it possible to remove a class by removing its cpp/header file and without altering any other C++ code. Also, I can have my main.cpp clean and don't need to include all the header files of the registered classes.

How do I have declarative, bidirectional bindings involving QML MouseAreas?

走远了吗. 提交于 2020-01-06 07:44:46
问题 I've created a QML UI that has a dial and a custom control. The custom control is basically a progress bar with a MouseArea to allow the user to set the value by clicking it. As Qt's property binding docs point out, as soon as I assign to the custom control's value from Javascript in the MouseArea click handler, I lose the declarative binding between it and the dial. Is it possible to make this binding bidirectional, or even better, to link the values of both controls to a single value above

How do I have declarative, bidirectional bindings involving QML MouseAreas?

[亡魂溺海] 提交于 2020-01-06 07:44:11
问题 I've created a QML UI that has a dial and a custom control. The custom control is basically a progress bar with a MouseArea to allow the user to set the value by clicking it. As Qt's property binding docs point out, as soon as I assign to the custom control's value from Javascript in the MouseArea click handler, I lose the declarative binding between it and the dial. Is it possible to make this binding bidirectional, or even better, to link the values of both controls to a single value above

Quick Controls 2 bad looking

浪尽此生 提交于 2020-01-06 07:07:50
问题 Qt 5.10, Windows 10 desktop. The following QML code: import QtQuick 2.10 import QtQuick.Window 2.10 import QtQuick.Controls 2.3 import QtQuick.Layouts 1.3 Window { visible: true width: 250 height: 100 title: qsTr("My app") GridLayout { columns: 2 Label { text: "Setting1:" } ComboBox { model: ["100%", "90%", "80%", "70%", "60%", "50%", "40%", "30%"] } CheckBox { id: tidle text: "Setting2:" } ComboBox { model: ["90%", "80%", "70%", "60%", "50%", "40%", "30%"] enabled: tidle.checked } } } gives

QML - Import external JavaScript file

送分小仙女□ 提交于 2020-01-06 07:00:59
问题 I can import JavaScript files which are already part of the project tree like this: import "myFile.js" as MyFile Is there any way to do this for external files that aren't already included in my project, i.e. by passing an absolute or relative path to the file on my disc? 回答1: For some questions that go like: Is it possible to do something like [this...] usually the easiest way, is to try it out. In your question a important detail is missing: Is the QML file in question in a qrc -file or not