pyside2

Text styling in QTableView with PySide2

心已入冬 提交于 2019-12-01 13:02:16
问题 I have a QTableView populated with a proper model. I would like to change the style of the text based on the context of it: The text, if there is something between parenthesis, just this part of text should change to green color -parenthesis included- (and bold, just if it is not harder). If you can provide a snippet or super simple example, I appreciate it. 回答1: You have to use a delegate that uses QTextDocument : import random from PySide2 import QtCore, QtGui, QtWidgets words = '''Lorem

Embed Pyqtgraph to PySide2

ぐ巨炮叔叔 提交于 2019-11-30 23:56:50
I'd like to implement a PyQtGraph PlotWidget into a PySide2 application. With PyQt5 everything works. With PySide2 I get the Error shown at the bottom. I already found out, that there's some work in progress, but also it seems that a few people managed to get this working. However, I was not able yet. I am using Pyqtgraph 0.10 and not the developer branch. Shall I change? What do I need to do? from PySide2.QtWidgets import QApplication, QMainWindow, QGraphicsView, QVBoxLayout, QWidget import sys import pyqtgraph as pg class WdgPlot(QWidget): def __init__(self, parent=None): super(WdgPlot, self

Embed Pyqtgraph to PySide2

╄→尐↘猪︶ㄣ 提交于 2019-11-30 18:11:26
问题 I'd like to implement a PyQtGraph PlotWidget into a PySide2 application. With PyQt5 everything works. With PySide2 I get the Error shown at the bottom. I already found out, that there's some work in progress, but also it seems that a few people managed to get this working. However, I was not able yet. I am using Pyqtgraph 0.10 and not the developer branch. Shall I change? What do I need to do? from PySide2.QtWidgets import QApplication, QMainWindow, QGraphicsView, QVBoxLayout, QWidget import

PySide Signal argument can't be retrieved from QML

两盒软妹~` 提交于 2019-11-30 09:23:52
问题 I've noticed that QML can receive a signal emitted from Python by using the Connections object. Unfortunately, I can't figure out how to get that object to receive the arguments of that signal. I've created a minimal test case that demonstrates what I want to do: min.py from PySide import QtCore, QtGui, QtDeclarative import sys # init Qt app = QtGui.QApplication(sys.argv) # set up the signal class Signaller(QtCore.QObject): emitted = QtCore.Signal(str) signaller = Signaller() # Load the QML

PySide Signal argument can't be retrieved from QML

自古美人都是妖i 提交于 2019-11-29 16:09:38
I've noticed that QML can receive a signal emitted from Python by using the Connections object. Unfortunately, I can't figure out how to get that object to receive the arguments of that signal. I've created a minimal test case that demonstrates what I want to do: min.py from PySide import QtCore, QtGui, QtDeclarative import sys # init Qt app = QtGui.QApplication(sys.argv) # set up the signal class Signaller(QtCore.QObject): emitted = QtCore.Signal(str) signaller = Signaller() # Load the QML qt_view = QtDeclarative.QDeclarativeView() context = qt_view.rootContext() context.setContextProperty(

Registering a Python list property to QML in pyside2

删除回忆录丶 提交于 2019-11-29 08:59:59
I'm trying to load a spreadsheet and pass a list of the worksheets back to my QML interface. But I'm unable to find a way to provide a list(and later a dictionary) back to the QML script. Here's my QML: FileDialog { id: openDialog title: "Open spreadsheet" nameFilters: [ "Excel files (*.xls *.xlsx)", "All files (*)" ] selectedNameFilter: "Excel files (*.xls *.xlsx)" onAccepted: { file.load(fileUrl) console.log(file.name) console.log(file.sheetnames) } onRejected: { console.log("Rejected") } } Here's the my python class: class File(QtCore.QObject): def __init__(self, *args, **kwargs): super

PySide2 not closing correctly with basic example

丶灬走出姿态 提交于 2019-11-28 12:19:31
When I run the basic script: import sys from PySide2.QtWidgets import QApplication, QLabel app = QApplication(sys.argv) label = QLabel("Hello World") label.show() app.exec_() forthe first time it all works fine. However, if I run it a second time I get: File "../script.py", line 17, in <module> app = QApplication(sys.argv) RuntimeError: Please destroy the QApplication singleton before creating a new QApplication instance. I am running the scripts in an Ubuntu machine. I get the same error in python2 and python3. Thanks ! Probably your IDE has already created a QApplication, so the solution is

PySide2 not closing correctly with basic example

六眼飞鱼酱① 提交于 2019-11-27 07:01:45
问题 When I run the basic script: import sys from PySide2.QtWidgets import QApplication, QLabel app = QApplication(sys.argv) label = QLabel("Hello World") label.show() app.exec_() forthe first time it all works fine. However, if I run it a second time I get: File "../script.py", line 17, in <module> app = QApplication(sys.argv) RuntimeError: Please destroy the QApplication singleton before creating a new QApplication instance. I am running the scripts in an Ubuntu machine. I get the same error in

Registering a Python list property to QML in pyside2

青春壹個敷衍的年華 提交于 2019-11-26 21:45:23
问题 I'm trying to load a spreadsheet and pass a list of the worksheets back to my QML interface. But I'm unable to find a way to provide a list(and later a dictionary) back to the QML script. Here's my QML: FileDialog { id: openDialog title: "Open spreadsheet" nameFilters: [ "Excel files (*.xls *.xlsx)", "All files (*)" ] selectedNameFilter: "Excel files (*.xls *.xlsx)" onAccepted: { file.load(fileUrl) console.log(file.name) console.log(file.sheetnames) } onRejected: { console.log("Rejected") } }