pyside2

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

background color of cells in QTableview, PySide2

此生再无相见时 提交于 2019-12-20 03:21:54
问题 Is it possible to conditionally change the background color of items in a QTableView, using PySide2? I've read a lot on the model view framework . I cannot figure out if it is necessary to use a Delegate or not. Recently I was able to get a column of checkboxes without a Delegate. I believe that the virtual methods setItemData(index, roles) and itemData(index) could be what I need. However, there is no QMap in PySide2. My model must need somewhere to store the extra information to be used by

Installing PySide for Python-3.6

若如初见. 提交于 2019-12-17 19:37:54
问题 When I try to install PySide for Python-3.6, it says it is only compatible until Python-3.4. Is there any work-around to get it installed for Python-3.6? Only these Python versions seem to be supported: [(2, 6), (2, 7), (3, 2), (3, 3), (3, 4)]. 回答1: Firstly, it should be pointed out that PySide depends on Qt4, which is no longer officially supported (as of December 2015). In consequence, all development efforts are now focused on PySide2 and Qt5. According to this tracker issue, there are no

RuntimeError: Please destroy the QApplication singleton before creating a new QApplication instance

假装没事ソ 提交于 2019-12-12 12:16:32
问题 When i run python-pyside2 project server first, then it works well. And the site also work well, but if i press F5 btn to refresh in browser. Site shows error page Runtime at/ import sys from urllib.request import urlopen from bs4 import BeautifulSoup from PySide2.QtGui import * from PySide2.QtCore import * from PySide2.QtWebKitWidgets import * from PySide2.QtWidgets import QApplication class dynamic_render(QWebPage): def __init__(self, url): self.frame = None self.app = QApplication(sys.argv

What are the differences between creating signals in these two different ways?

天涯浪子 提交于 2019-12-11 19:10:54
问题 Using PySide2, it's possible to create signals in two ways that I know of: file_changed = Signal() or @Signal def file_changed(self): pass They both seem to do the same thing. What if I want a signal that can emit a value? I know I can do: file_changed = Signal(str) ... def load_file(self, file_name): self.file_changed.emit(file_name) But what is the equivalent using the @Signal decorator? 来源: https://stackoverflow.com/questions/57204514/what-are-the-differences-between-creating-signals-in

Exposing QML Components to each other in Qt Creator

时光总嘲笑我的痴心妄想 提交于 2019-12-11 16:58:14
问题 I'm developing a dashboard application using Qt-Quick with PySide2 and am having trouble exposing my QML components in Qt Creator's design mode. My folder structure looks something like this: myapp/ ├── mycomponents │ ├── component1.qml │ └── component2.qml │ └── etc.. ├── pages │ ├── page1.qml │ └── page2.qml └── app.qml I can use all components from myapp/mycomponents by importing the appropriate .qml files or it's parent directory using relative paths: // inside page1.qml import "..

How do I get Intellisense / tab-completion working on Python package PySide2.QtCore.Qt module, using VS Code editor?

一曲冷凌霜 提交于 2019-12-11 14:20:34
问题 I'm fairly new to Python, but have gotten it set up and working in Visual Studio Code (Note: this is not the same as Visual Studio). I'm working through a GUI tutorial for Qt for Python, using the PySide2 package. Most symbols are giving me code completion through the VS Code's Microsoft Python extension's Intellisense feature, but one, the PySide2.QtCore.Qt module is not. Intellisense still does give some symbols, but they are all symbols with double underscores at the start and end, and one

PySide2 QListView QTableView sync problem

▼魔方 西西 提交于 2019-12-11 07:45:13
问题 It is python/PySide2 interface related problem, as much as I tried, I couldn't make it sync (QListView and QTableView). I will try to simplify it, instead of explaining the whole complicated thing which is much bigger with full of forms stuff in QT... Just imagine to have a data structure (I guess, model) like the following: dict_of_dicts={ 'dict1':{'k1':'v1', 'k2':'v2', 'k3':'v3'}, 'dict2':{'k4':'v4'}, 'dict3':{'k5':'v5', 'k6':'v6', 'k7':'v7'}, } I would like to have a form (or dialog), with

PySide2 QUiLoader returns an empty window

不问归期 提交于 2019-12-11 06:02:12
问题 PySide2(5.6.0~a1) Qt UI file loader returns an empty window whereare PyQt5 loader works fine. Could you explained to me where I am wrong. Non Working PySide2 version: import sys from PySide2.QtWidgets import QDialog, QApplication from PySide2 import QtUiTools class AppWindow(QDialog): def __init__(self): super().__init__() self.ui = QtUiTools.QUiLoader().load("dialog1.ui") self.show() app = QApplication(sys.argv) w = AppWindow() sys.exit(app.exec_()) Working PyQt5 version: import sys from

How to load a Qt Designer file (.ui) in a QWizardPage using PySide2

旧时模样 提交于 2019-12-11 05:14:12
问题 I want to design my QWizardPages in Qt Designer and I want to load them into my Python program with PySide2. Previously I have been using PyQt5 without any problems but making the switch to PySide2 seems harder then expected. The problem I am facing is that when I am adding a QWizardPage to my QWizard , the page is indeed added to the Wizard, but also an other (empty) page is added. I'm not able to find what I'm doing wrong so I was wondering if someone can have a look. I have tried to add