qml

QML: using Matrix4x4 transform

隐身守侯 提交于 2019-12-24 04:01:05
问题 How do you rotate, using Matrix4x4 transform, a QML item around another axis than z, with the center of the item as origin of the transformation? To rotate around the y axis with (0,0) as origin, I tried naively: Image { source: "..." width: 100 height: 100 transform: Matrix4x4 { property real a: Math.PI / 4 matrix: Qt.matrix4x4( Math.cos(a), 0, -Math.sin(a), 0, 0, 1, 0, 0, Math.sin(a), 0, Math.cos(a), 0, 0, 0, 0, 1) } } As a result, I get a cut width item whereas I am looking for a

QML - How to change TextField font size

て烟熏妆下的殇ゞ 提交于 2019-12-24 03:21:15
问题 How can I set the font size of a TextField element in QML? wanna change size of the placeholderText and also for the text which the user enters. I tried with a lot of ways without luck! TextField { id: name_TextField; horizontalAlignment: Text.AlignHCenter; Layout.preferredWidth: parentCLayer.width * 0.90; Layout.preferredHeight: 50 style: TextFieldStyle { font.pixelSize: 20 // This doesn't seem to work either } placeholderText: qsTr("Your name here") } 回答1: You can use the style property to

How to make double MouseArea take effect?

╄→尐↘猪︶ㄣ 提交于 2019-12-24 02:56:21
问题 Here is my QML code : Rectangle { ..... Rectangle { ....height and width is smaller than parent MouseArea { id: mouseArea2 anchors.fill: parent hoverEnabled: true onEntered: { console.log("enter 2") } } } MouseArea { id: mouseArea1 anchors.fill: parent hoverEnabled: true onEntered: { console.log("enter 1") } } } Only mouseArea1 takes effect. If I remove mouseArea1 then mouseArea2 takes effect. So I think the mouse event must be handled by mouseArea1 and let it couldn't be passed to mouseArea2

How to use a custom Qt type with a QML signal?

浪尽此生 提交于 2019-12-24 02:18:13
问题 I've created a custom type inside my Qt 5.2 qml application class Setting : public QObject { Q_OBJECT Q_PROPERTY(QString key READ key WRITE setKey) Q_PROPERTY(QVariant value READ value WRITE setValue) public: Setting(QObject * parent = 0); QString key() const; void setKey(QString const & key); QVariant value() const; void setValue(QVariant const & value); private: QString m_key; QVariant m_value; }; and registered it in my main function: int main(int argc, char *argv[]) { QApplication app

How to drag an item outside a ListView in QML

主宰稳场 提交于 2019-12-24 02:05:21
问题 I am developing a QML application which basically contains two ListView. I would like to copy a QML item from one ListView to another. I tried to handle this by setting Drag property in the delegate but the item cannot go outside the view when I drag the item, I think the Flickable container handles mouse events. So, I want to try the following: create a mousearea which overlaps the to ListView create a new object by calling **createComponent() / createObject()** reparent this object to the

Use QQuickView or QQmlApplicationEngine to switch between pages from ApplicationWindow

 ̄綄美尐妖づ 提交于 2019-12-24 01:19:16
问题 I'd like to use an ApplicationWindow as a main file and be able to switch to other QML files from C++ with QQuickView::setSource(const QUrl & url) . Basically it would do this: start-up => loads main.qml ( ApplicationWindow ) => click on help button => C++ loads help.qml file => etc. int main(int argc, char *argv[]) { QApplication app{argc, argv}; CustomQQuickView view; view.setSource(QUrl{"qrc:/main.qml"}); view->show(); return app.exec(); } main.qml ApplicationWindow { visible: true width:

QML reports ReferenceError: XYZ is not defined on C++ object added to context

烈酒焚心 提交于 2019-12-24 00:54:55
问题 I've started learning QML recently (after trying it out a long time ago) and I'm stuck at the way Qt C++ code interacts with QML and vice versa. I have a Counter which has the following header: #include <QObject> #include <QTimer> class Counter : public QObject { Q_OBJECT Q_PROPERTY(int count READ getCount WRITE setCount NOTIFY signalCountChanged) public: Counter(QObject *parent = Q_NULLPTR); int getCount(); void setCount(int count); signals: void signalCountChanged(int); public slots: void

how to create a scrollbar for rectangle in QML

为君一笑 提交于 2019-12-24 00:43:34
问题 like the web pages,when content's high beyond the rectangle,there is a scrollbar. Is there anyone else who can help me? I have tried with listview,but I can't use it in a rectangle 回答1: There is an example in the docs, how to use ScrollBar without a Flickable: import QtQuick 2.7 import QtQuick.Controls 2.0 Rectangle { id: frame clip: true width: 160 height: 160 border.color: "black" anchors.centerIn: parent Text { id: content text: "ABC" font.pixelSize: 160 x: -hbar.position * width y: -vbar

How can I propagate hover or mousearea update events to lower elements in QML?

[亡魂溺海] 提交于 2019-12-24 00:39:28
问题 I have some sibling Rectangle elements with a radius property so they appear as circles. Each has a child Item that has a child MouseArea, the purpose of the Item being to implement a "round mouse area" effect (original SO answer). The Item and MouseArea are instrumented such that clicks and drags will only take effect within the visible circular shape of the Rectangle, not within the bounding box that is the real footprint of the Rectangle. Unfortunately there is a glitch illustrated below.

QtQuick.Controls 2 StackView and destroyOnPop

我们两清 提交于 2019-12-24 00:25:16
问题 I have application which uses StackView and pushes a lot of dynamic created objects into this StackView and I need some way to destroy this objecst when they are popped from StackView. If I use Controls 1 Stackview, I can just push object with destroyOnPop property (like it was shown in this question): tablesStack.push({item: view, destroyOnPop: true}) but it doesn't applicable to Controls 2 StackView. What is correct solution of this problem? I know only one way: call object.destroy() with