qt-quick

QML view wont update when adding a new item to a QAbstractListModel based model

自闭症网瘾萝莉.ら 提交于 2019-12-19 08:02:14
问题 I've figured out how to bind a model derived from QAbstractListModel to a QML view. But the next thing I tired does not work. If a new Item is added to the model the QML view will not update. Why is that? DataObject.h class DataObject { public: DataObject(const QString &firstName, const QString &lastName): first(firstName), last(lastName) {} QString first; QString last; }; SimpleListModel.h class SimpleListModel : public QAbstractListModel { Q_OBJECT enum /*class*/ Roles { FIRST_NAME = Qt:

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

Qt Transform matrix

人盡茶涼 提交于 2019-12-17 19:41:09
问题 I need to manipulate QML items through QMatrix4x4, in order to apply some perspective transformations. Basically, I defined the class Transform to use an object QMatrix4x4 as argument for the transform field of the QML Item class Transform : public QQuickTransform{ Q_OBJECT Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix NOTIFY matrixChanged) public: explicit Transform(QQuickItem *parent = 0); QMatrix4x4 matrix() const; void setMatrix(QMatrix4x4 matrix); virtual void applyTo

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

Custom attached properties in QML

巧了我就是萌 提交于 2019-12-12 17:54:28
问题 I'm creating a custom QML component (a specialization of ListView that allows multiple selection). I'd like to provide attached properties to objects provided to my component. I see how to create attached properties using C++. However, I cannot find information on adding custom properties in pure QML. Is this possible using QML? 回答1: Is this possible using QML? No. 回答2: There is an alternative, easy and clean way to this in QML - just use an adapter object that implements the desired

Best way to access a cpp structure in QML

Deadly 提交于 2019-12-12 08:57:20
问题 I need to pass structures between cpp and QML. If i use property i should create an individual set and get functions, My structure contains minimum 5 members so i felt it's not good to use set and get for all those members. Following is an example of what i am trying to do : MyClass.h #include <QObject> #include <QDebug> using namespace std; struct MyStruct { Q_GADGET int m_val; QString m_name1; QString m_name2; QString m_name3; QString m_name4; Q_PROPERTY(int val MEMBER m_val) Q_PROPERTY

How to prevent blurry QtGraphicalEffects from being cut off?

青春壹個敷衍的年華 提交于 2019-12-12 08:53:28
问题 I'm trying to add effects to my items using QtQuick 2 with QtGraphicalEffects, but I don't quite understand how to tweak really blurry effects to look right. In this case, the drop shadow is poorly sized and is getting clipped at the edges before it entirely fades away. How can I make it blend in nicely and not get cut off? This is the code for the window: import QtQuick 2.0 import QtGraphicalEffects 1.0 Item { width: 250 height: 75 Text { id: textItem x: 10; y: 10 text: "how can I fix my

Delay of tooltip dissapear in QML

人盡茶涼 提交于 2019-12-12 03:43:49
问题 I'm writing a program where there will be some buttons and tooltips connected with them. I would like the tooltip to disappear with a delay (couple of seconds). I made my own button and my own tooltip in two separate qml files. Tooltip pops up with delay, but I would like it to stay visible for some time and then begin to disappear. Maybe somebody's made something similar. So please, help. 回答1: IMHO, this may be a cleaner way to implement a tooltip component, though it spans across three

How to remove a specific row from QML table

元气小坏坏 提交于 2019-12-12 00:58:52
问题 I am working with QML Tableview, I have created a model to fill data in the rows of QML Table. I am able to fill data succesfull in the table row when i press the “New row data” button, i am also able to remove the rows from the table using “Delete the row” tool button. Now i am facing following problems: I want to select the row which will be deleted by “delete the row” button, by using up and down buttons. So please tell me how i can select a table row entry using up and down tool button