qtquick2

How to make a “True Transparent” window to cursor, preferably on a pure QML? (Qt 5.7)

蹲街弑〆低调 提交于 2019-12-24 05:45:23
问题 "True Transparency" explanation (image, 76kb). On that image ApplicationWindow have a visually transparent layer. But in fact, cursor does not go to the window behind ApplicationWindow (in this case - QT Creator). "True Transparency" is achieved if add (uncomment) "Qt.WindowTransparentForInput" flag, but the buttons are no longer available (it's are obvious, I know). I have tried a various flags with similar meanings (from the documentation), but did not find a working combination - cursor

How to integrate a custom GraphicsItem into a QML scene?

大兔子大兔子 提交于 2019-12-24 05:36:08
问题 Assume you have created the following custom QGraphicsRectItem in C++: class MyCustomItem : public QGraphicsRectItem { public: MyCustomItem(MyCustomItem* a_Parent = 0); virtual ~MyCustomItem(); // specific methods private: // specific data }; Assume also that you have defined in a QML script an ApplicationWindow : // main.qml import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.0 ApplicationWindow { id: myWindow title: qsTr("My Window") width: 640 height: 480 visible: true }

Using TableView as ListView-delegate

馋奶兔 提交于 2019-12-24 04:32:35
问题 I have a model that contains several QStandardItemModels . Now I want to create a view that displays a TableView for each QStandardItemModel . I had the idea to have a ListView that has a TableView as delegate, something like this: ListView { id: myListView anchors { fill: parent margins: 5 } model: testModel delegate: CompareDelegate { } } And in CompareDelegate.qml : Item { id: base width: 500 height: 300 TableView { anchors.fill: parent } } How do I get the TableView inside the delegate 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 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.

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

Bounding box of wrapped text

二次信任 提交于 2019-12-23 18:55:45
问题 I want to draw a rectangle around a QML Text object that is using word wrapping. TextMetrics seems like it would be ideal, but it does not appear to support wrapped text. How can I measure how text is laid out in a Text object? Must I match the wrapping logic and manually calculate the offsets using TextMetrics and FontMetrics? 回答1: You can use contentWidth and contentHeight: Text { text: "..." wrapMode: Text.Wrap Rectangle { border.color: "red" color: "transparent" width: parent.contentWidth

Presence and location of a property in a QML singleton source results in arbitrary bugs

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 17:59:40
问题 So I was finally able to reproduce it in an MCVE: // S_Settings.qml pragma Singleton import QtQuick 2.7 Item { property real bsize: 50 } // in main() qmlRegisterSingletonType(QUrl(QStringLiteral("qrc:/S_Settings.qml")), "Set", 1, 0, "SS"); // main.qml import QtQuick 2.7 import QtQuick.Window 2.2 import Set 1.0 Window { id: main visible: true width: 300 height: 200 Rectangle { anchors.centerIn: parent width: SS.bsize * 4 height: SS.bsize * 2 radius: SS.bsize * .5 color: "red" border.color: