qt5

PyQt5 QML treeview example

让人想犯罪 __ 提交于 2021-01-27 17:54:01
问题 I try to setup a simple treeview example with PyQt5.6 (Python 3.4) and QML. I just found a few C++ examples, but nothing related to PyQt. I picked up the simpletreemodel example comming with PyQt source and modified it (https://github.com/baoboa/pyqt5/tree/master/examples/itemviews/simpletreemodel). Most likely something is wrong with the model. I got two error messages: simpletreemodel.qml:13:5: QML TreeView: Binding loop detected for property "model" ...qt/5.6/gcc_64/qml/QtQuick/Controls

QVBoxLayout: How to align widgets to the top using Qt designer

十年热恋 提交于 2021-01-27 04:38:22
问题 I'm using qt designer only for ui layout This is almost the same question as this one : QVBoxLayout: How to vertically align widgets to the top instead of the center but i'm interested on how to do that in qt designer. I don't see any option in QVBoxLayout for that top alignment. 回答1: Right-click the relevant widget and select Layout alignment > Top. (NB: the new alignment will only be shown in preview mode). 来源: https://stackoverflow.com/questions/42741396/qvboxlayout-how-to-align-widgets-to

Qml: how to make text or label selectable?

Deadly 提交于 2021-01-26 21:39:53
问题 Let's say I have text component: Text { text: "Hello" wrapMode: Text.WordWrap } How to make it selectable? 回答1: That is a bug reported: QTBUG-14077, and the workaround is to use TextEdit in read-only mode: TextEdit { text: "Hello" readOnly: true wrapMode: Text.WordWrap selectByMouse: true } 来源: https://stackoverflow.com/questions/49784099/qml-how-to-make-text-or-label-selectable

Qml: how to make text or label selectable?

痴心易碎 提交于 2021-01-26 21:37:21
问题 Let's say I have text component: Text { text: "Hello" wrapMode: Text.WordWrap } How to make it selectable? 回答1: That is a bug reported: QTBUG-14077, and the workaround is to use TextEdit in read-only mode: TextEdit { text: "Hello" readOnly: true wrapMode: Text.WordWrap selectByMouse: true } 来源: https://stackoverflow.com/questions/49784099/qml-how-to-make-text-or-label-selectable

Why does the address of QVector change when size() has not surpassed capacity() after calling QXYSeries::replace()?

回眸只為那壹抹淺笑 提交于 2021-01-20 08:28:49
问题 I have a small test program that inserts values into a QVector. The QVector is reserved at start to have a minimum amount of memory allocated. I verify that the capacity is correct and that the size of the QVector does not surpass the capacity. I observe that appending data to the QVector does not change the address of the first element. All good this far. I then use the replace() method of the QSplineSeries class to copy the data from the vector to the chart. I again check the address of the

How to stream the video using VLC-QT wrapper

孤人 提交于 2021-01-05 07:05:07
问题 I want to stream the video using RTSP, HTTP and UDP as they are supported by vlc . I am using Qt5 and as Qt don't have that much good media libraries so I go for open source and now using libvlc through VLC-Qt wrapper. I am able to receive the stream videos in my program, The source code for receiving the streaming video is given below void player::on_actionNETWORK_STREAM_triggered() { QString url= QInputDialog::getText(this,tr("Open Url"),tr("Enter the URL you want to play")); if(url.isEmpty

How to call qt keyPressEvent(QKeyEvent *event) from qml Keys.onPressed

别说谁变了你拦得住时间么 提交于 2021-01-04 05:58:46
问题 I have a qml Window with an Item which has Keys.onPressed { } And I have a c++ class which has protected: void keyPressEvent(QKeyEvent *event); What needs to go inside the Keys.onPressed? I have tried myclass.keyPressEvent(event) and I have tried a public Q_INVOKABLE function (handleKeyPress) in my c++ class with parameter (QKeyEvent * event) from which I wanted to call the keyPressEvent . At runtime the former gives "TypeError: Property 'keyPressEvent' of object myclass is not a function"

Create a truly headless QApplication instance

可紊 提交于 2021-01-04 05:34:25
问题 I have a Qt 5.8 (via PyQt5) application whose many tests require a live QApplication instance in order to test gui widget interactions. However on my new Mac OS X (10.11.6) machine when running these tests windows are constantly being created and destroyed, causing the entire system's UI to become highly unstable (although the tests pass as expected). My tests do not even call QApplication.exec() - the QApplication() constructor is enough to cause this. On my linux machine this is no issue,

Create a truly headless QApplication instance

倾然丶 夕夏残阳落幕 提交于 2021-01-04 05:34:22
问题 I have a Qt 5.8 (via PyQt5) application whose many tests require a live QApplication instance in order to test gui widget interactions. However on my new Mac OS X (10.11.6) machine when running these tests windows are constantly being created and destroyed, causing the entire system's UI to become highly unstable (although the tests pass as expected). My tests do not even call QApplication.exec() - the QApplication() constructor is enough to cause this. On my linux machine this is no issue,

How to show SVG image in PyQT5 from string/xml stream?

这一生的挚爱 提交于 2021-01-03 08:47:22
问题 In a Python3/QT5 application, I'm trying to show a SVG image built originally as a string. I need to manipulate this SVG image (e.g. change its color), so I have the string changing over time. Here is a minimal working example: import sys from PyQt5.QtWidgets import QApplication from PyQt5.QtSvg import QSvgWidget svg_str = """<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg width="300" height="300" viewBox="0 0 300 300" id="smile" version="1.1"> <path style="fill:#ffaaaa" d="M 150