qml

Does Python go well with QML (Qt-Quick)?

无人久伴 提交于 2019-12-20 08:59:17
问题 I am a beginner in Qt-Quick. I am not aware of Qt which is a basis for QML. And also I'm not familiar with C++ which is again main supported language for both Qt and QML. I'm aware JS can do a lot of logic in QML layer itself. But if we need interactions with OS, then we have to use some base language. As I'm comfortable with Python, I m planning for " QML-JS-Python " combination. So, My questions: For advanced Application and Game development Does Python & Qt-Quick do well hand in hand? Is

Get return value in QML from Python method

久未见 提交于 2019-12-20 05:37:11
问题 I'm trying to call a Python method from QML and use the return value. QML receives undefined, from the Python method. When passed back to Python it is just an empty string. import sys from PyQt5.QtCore import QObject, pyqtSlot from PyQt5.QtWidgets import QApplication from PyQt5.QtQml import QQmlApplicationEngine class InPython(QObject): @pyqtSlot(str, ) def login(self, Login): print(Login) return "a" if __name__ == "__main__": app = QApplication(sys.argv) engine = QQmlApplicationEngine()

How to package custom controls in QML?

99封情书 提交于 2019-12-20 04:58:10
问题 I would like to create a library of QML custom controls that I would provide to my customers. At the same time I don't want my customers to "reverse-engineer" my controls by peeking into the QML source code. What are my best options to avoid this? The ideal scenario would that I provide my controls as a compiled library that they could import in their own projects. My target platforms are iOS and Android. 回答1: How can I create the package for custom QML controls? These controls should not be

Set items to QML ListModel dynamicaly with PyQt

杀马特。学长 韩版系。学妹 提交于 2019-12-20 04:54:10
问题 I have a QML that represent schedule, that get values from database, so I need insert values to ListModel from my python code. QML looks like that: function append(newElement) { scheduleList.model.append(newElement) } ListView { id: scheduleList model: scheduleModel delegate: scheduleItem section.property: "day" section.delegate: sectionDelegate } Component { id: scheduleItem Rectangle { Row { spacing: 15 Text { text: lesson } Text { text: subject } } } } Component { id: sectionDelegate

How can I change all the points in an XYSeries in qml or PySide2?

一个人想着一个人 提交于 2019-12-20 04:24:26
问题 I'm kinda new to PySide2 and QML and I really need a way to replace all the points in an XYSeries at once. Since the QML item does not have a function that does so, I thought I had to create a custom class (that would inherits from QtCharts.QXYSeries), implement the function I need and then register the new type with PySide2.QtQml.qmlRegisterType, but I don't know how that should be done and I haven't been able to find an answer online (or at least one that I could understand). So, to cut a

Connect QML signal to PySide2 slot

泪湿孤枕 提交于 2019-12-20 04:23:47
问题 I have some expirience using Qt/C++ and now I want to switch to PySide2 + QML. I want to connect ui signals, such as clicking a button, to python slot I have seen many examples, but they all differ, i guess PyQt/PySide is changing quickly now Can you provide me modern and clean way of connecting a QML signal to PySide Slot? For example clicking a Button to printing some text in python console. Here's my simple code example main.py from PySide2.QtGui import QGuiApplication from PySide2.QtQml

How to switch focus among 50 text fields in QML?

ε祈祈猫儿з 提交于 2019-12-20 04:15:24
问题 I want to switch focus from one field to the next when the user presses Enter: how would I go about it? The items are arranged in a grid, as follows: Grid { x: 5 y: 3 rows: 5 columns: 20 spacing: 10 Repeater { model: 50 TextField { width: 28 height: 50 color: "green" text: "0000" font.pixelSize: 12 validator: IntValidator { bottom: -256 top: 256 } } } } 回答1: Since TextField inherits from Item you can use the existing focus chain using nextItemInFocusChain(). Just add the following line to the

ListView in subwindow triggers immediate close, or whilst scrolling

风格不统一 提交于 2019-12-20 04:13:01
问题 I have rather strange scenario whereby if I launch a subwindow that contains a ListView with a moderately complex delegate and enough items to comfortably exceed the visible area, the entire subwindow will immediately close on launch. Reducing the complexity of the delegate will allow the window to open, but then rapidly scrolling the ListView will forcibly close it. This SSCCE triggers the effect on my laptop, but on a more powerful machine it may only do it whilst scrolling (or perhaps the

Qml环形倒计时

廉价感情. 提交于 2019-12-20 03:43:33
项目中有一个界面是输入密码错误时,进行倒计时界面。由于项目时基于QML写的,所以研究了下用Canvas画倒计时界面: 项目中的界面: 我实现的: 上传的gif图,不会动啊 实现的过程中走了许多弯路,试了多种方法组合和函数。如果项精准控制,需要对以下函数有深刻认识: context.arc(x,y,r,sAngle,eAngle,counterclockwise); context.scale(scalewidth,scaleheight); context.translate(x,y); 需要对以上三个函数有清晰的认识。 绘图关键代码如下: onPaint: { var ctx = getContext("2d"); ctx.save(); ctx.clearRect(0, 0, canvas.width, canvas.height); let x = this.x + this.width / 2; ctx.translate(x, 0); ctx.scale(-1, 1); ctx.translate(-x, 0); ctx.beginPath(); ctx.lineWidth = 5; ctx.strokeStyle = “darkblue”; ctx.arc(canvas.centerWidth, canvas.centerHeight, canvas.radius,

QQuickWidget grab image

巧了我就是萌 提交于 2019-12-20 03:27:30
问题 I am saving an image of a QQuickWidget with several QML children but all I have is a blank image. C++ side: QQuickWidget* content.. content->setSource(QUrl("qml:/main.qml")); QPixmap *pm = content->grab(QRect(QPoint(0,0),QSize(-1,-1)); pm->save("someFilename.png", 0, 100); QML side: Rectangle{ width: 5; height: 5; color: "yellow"; objectname: "rootobj"} In the QML I wish to dynamically add children and be able to show them in the image. I have tried QQuickWindow grabWindow method with a