qt-quick

QScrollArea in Qml: Flickable + QQuickPaintedItem

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 10:33:39
问题 I'm trying to realize something similiar to QScrollArea (in widgets world) with the help of Qml. I decided to probe Flickable plus QQuickPaintedItem based item (named Drawer in my case): Flickable { ... onContentXChanged(): { drawer.update() } Drawer { id: drawer ... } Drawer's render target is set to FrameBufferObject . Its paint function looks like this: void Drawer::paint(QPainter *painter) { // Some function to compute rect which is needed to be redrawn QRect updateRect =

QScrollArea in Qml: Flickable + QQuickPaintedItem

☆樱花仙子☆ 提交于 2020-01-02 10:33:29
问题 I'm trying to realize something similiar to QScrollArea (in widgets world) with the help of Qml. I decided to probe Flickable plus QQuickPaintedItem based item (named Drawer in my case): Flickable { ... onContentXChanged(): { drawer.update() } Drawer { id: drawer ... } Drawer's render target is set to FrameBufferObject . Its paint function looks like this: void Drawer::paint(QPainter *painter) { // Some function to compute rect which is needed to be redrawn QRect updateRect =

Better way to reparent visual items in QML

末鹿安然 提交于 2020-01-02 05:46:07
问题 It would seem that in the design of QML user reparent was not really "envisioned", because even though it is possible, it involves creating and changing states, which is just not convenient to add to each and every item. import QtQuick 1.0 Item { width: 200; height: 100 Rectangle { id: redRect width: 100; height: 100 color: "red" } Rectangle { id: blueRect x: redRect.width width: 50; height: 50 color: "blue" states: State { name: "reparented" ParentChange { target: blueRect; parent: redRect;

Inner shadow on QML Rectangle

ぃ、小莉子 提交于 2020-01-02 04:15:07
问题 How do I implement a Rectangle in QML with an inner shadow? See example in link below: Create inner shadow in UIView UPDATE: Here's a simplified version of what I'm trying to do (which does not show any shadow): import QtQuick 2.0 import QtGraphicalEffects 1.0 Item { width: 400 height: 400 Item { anchors.fill: parent Rectangle { id: myRectangle anchors.centerIn: parent width: 200 height: 200 color: "grey" } } InnerShadow { anchors.fill: myRectangle cached: true visible: true horizontalOffset:

Measuring elapsed time in QML

跟風遠走 提交于 2020-01-02 03:40:07
问题 Let's consider the following example: we have a Qt Quick Controls Button . The user clicks it twice within 5 seconds. After pushing the Button for the first time, the QML Timer is running for these 5 seconds. We want to measure the time elapsed between two clicks, with a millisecond accuracy. Unfortunately, the QML Timer can't show us the elapsed time. As suggested on the BlackBerry forums, it would be possible to compare the dates. This isn't very handy, though, since the first click might

64 bit integers in QML

五迷三道 提交于 2020-01-01 10:13:26
问题 How do I deal with 64 bit integers in QML? I know that useless Javascript can't handle them normally as it uses doubles for everything, and if I try to use them in a signal, everything gets set to undefined . Is there a way around this? Perhaps I have to use a QVariant or something? 回答1: Create your own Integer64 class derived from QObject and give it the functions you need, like class Integer64 : public QObject { Q_OBJECT public: // ... Q_PROPERTY(QString value READ value WRITE setValue

How to create grouped/nested properties?

人盡茶涼 提交于 2019-12-30 03:23:07
问题 I am trying to do nested properties like 'font.family' or 'anchors.fill', but I cannot initialize them in normal way because it prints 'Cannot assign to non-existent property'. Instead I am forced to use Component.onCompleted method. What's wrong? MyButtonStyling.qml: import QtQml 2.1 QtObject { property QtObject background: QtObject { property color pressed: "#CCCCCC" property color enabled: "#666666" property color disabled: "#555555" } } main.qml: import QtQuick 2.0 Item { width: 400

QML: Cannot read property 'xxx' of undefined

泄露秘密 提交于 2019-12-23 20:22:12
问题 ApplicationWindow { id: root property string rootName: "--rootName" visible: true width: 800 height: 400 title: qsTr("WatchFace Maker") WatchLcd{ property string watchLcdInApp: "watchLcdInApp" id: watchLcd } TextAdder{ id: textAdder Component.onCompleted: { console.log("APP: ", root.watchLcd.watchLcdInApp)//#Error!!! remove root, it works. } } } I want to know: Why it doesn't work when I add root id in above commented line? How do children component access sibling component's property if

Propagate QML events to C++

柔情痞子 提交于 2019-12-23 13:29:08
问题 I would like to propagate event from a QML signal handler to C++ procedure but don't know how to pass the "event object". Take a look at this situation and pay particular attention to SomeType . First I create a custom QML item with a slot that can be called from QML: class Tool : public QQuickItem { . . . public slots: virtual void onMousePositionChanged(SomeType *event); } Then, in QML, I create a MouseArea and an instance of my custom object to which I wanto to propagate events to.

Create QML object from C++ with specified properties

不想你离开。 提交于 2019-12-23 09:15:21
问题 Dynamically instantiating a QML object from C++ is well documented, but what I can't find is how to instantiate it with pre-specified values for it's properties. For example, I am creating a slightly modified SplitView from C++ like this: QQmlEngine* engine = QtQml::qmlEngine( this ); QQmlComponent splitComp( engine, QUrl( "qrc:/qml/Sy_splitView.qml" ) ); QObject* splitter = splitComp.create(); splitter->setProperty( "orientation", QVariant::fromValue( orientation ) ); The problem I have is