pyside2

PyInstaller and QML Files

点点圈 提交于 2021-02-10 16:50:14
问题 How can I include the QML file into my Python project as a single executable. When I run pyinstaller --onefile main.py , running the executable results in an error that the QML file is not found. Unless I use an absolute path or place view.qml in the same directory as my executable. I don't want to have a separate QML file, I want it combined into the executable. main.py: if __name__ == "__main__": app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() engine.load(QUrl("view.qml"))

Copy/paste text from QClipboard freezes program

喜欢而已 提交于 2021-02-10 14:14:55
问题 I have a QTableWidget that when a row is clicked, it selects all cells in that row. I am trying to add a "copy" functionality so that I can ^ctrl-c when row(s) are selected and paste into a text editor. However, with my current code, once i ^ctrl-c a row, the line that I copied keeps getting copied. I have implemented a print statement in my method "read_clipboard" to see whether or not the line copied was read, and this is how I found out that the line keeps getting copied as if in an

PySide2 QThread Error: QThread: Destroyed while thread is still running

旧街凉风 提交于 2021-02-07 10:07:21
问题 I am new to PySide2. I am just trying to launch a sample application and start a thread as the application starts and want to stop the thread as the application closes. When I am closing the application I am getting the following error: QThread: Destroyed while the thread is still running. The sample_ui.py is a python file that I converted from sample_ui.ui Code: import time import sys import sample_ui from PySide2 import QtWidgets from PySide2 import QtCore class MainWindow(QtWidgets

PySide2 QThread Error: QThread: Destroyed while thread is still running

浪尽此生 提交于 2021-02-07 10:04:32
问题 I am new to PySide2. I am just trying to launch a sample application and start a thread as the application starts and want to stop the thread as the application closes. When I am closing the application I am getting the following error: QThread: Destroyed while the thread is still running. The sample_ui.py is a python file that I converted from sample_ui.ui Code: import time import sys import sample_ui from PySide2 import QtWidgets from PySide2 import QtCore class MainWindow(QtWidgets

Pyside2 QAction triggers once automatically but not when user clicks the menu

佐手、 提交于 2021-02-05 11:51:44
问题 I've created a simple GUI using qt designer and imported it into my python project. The main window comes up, and the menus/buttons are responsive, but I cannot manage to connect my QActions to custom functions (I did it for buttons though, and it works). The weird thing is that my custom function ( on_action_clicked ) is called once when I run the application, but not when I click on the menu items or icons of the toolbar (I tried connecting both). Below are the test codes. Am I missing

Pyside2 QAction triggers once automatically but not when user clicks the menu

丶灬走出姿态 提交于 2021-02-05 11:50:10
问题 I've created a simple GUI using qt designer and imported it into my python project. The main window comes up, and the menus/buttons are responsive, but I cannot manage to connect my QActions to custom functions (I did it for buttons though, and it works). The weird thing is that my custom function ( on_action_clicked ) is called once when I run the application, but not when I click on the menu items or icons of the toolbar (I tried connecting both). Below are the test codes. Am I missing

Parsing property values from stylesheet for drawing custom widgets

一笑奈何 提交于 2021-02-05 11:20:07
问题 I have to create a couple of custom qt widgets, some of which use custom drawing. Those widgets should be styled via the companies qt stylesheet. This creates the problem that some custom widget need to retrieve a value from stylesheet that has been applied to the QMainWindow or QApplication . This value could either be one of qt's official properties or some custom qproperty-... property However, it is not trivial to access them from the widget. One option would be to get the stylesheet

Parent a QTreeWidgetItem to an existing QTreeWidgetItem to second column maintaining the first column

半腔热情 提交于 2021-02-05 11:11:05
问题 I created a QTreeWidget and parented a QTreeWidgetItem using the QTreeWidget.addTopLevelItem method. The QTreeWidgetItem are parented to each other with QTreeWidgetItem.addChild. Which works great. However, I want to add a check box that is flushed left and not right next to each QTreeWidgetItem (which is easy by adding QtCore.Qt.ItemIsUserCheckable). I can add a check box to the second column and maintain the tree. By all that gets messed up when I add the checkbox to the first column and

Parent a QTreeWidgetItem to an existing QTreeWidgetItem to second column maintaining the first column

流过昼夜 提交于 2021-02-05 11:09:13
问题 I created a QTreeWidget and parented a QTreeWidgetItem using the QTreeWidget.addTopLevelItem method. The QTreeWidgetItem are parented to each other with QTreeWidgetItem.addChild. Which works great. However, I want to add a check box that is flushed left and not right next to each QTreeWidgetItem (which is easy by adding QtCore.Qt.ItemIsUserCheckable). I can add a check box to the second column and maintain the tree. By all that gets messed up when I add the checkbox to the first column and

would like not clickable/highlighted icons in listWidget

﹥>﹥吖頭↗ 提交于 2021-02-05 08:08:54
问题 I have QListWidget in Pyside2 that has icons populating it. I dont like the icons taking on a shaded grey look when the mouse clicks them. Is there a way to disable this action? I will include a picture. 回答1: You have to use a delegate that disables the QStyle::State_Selected flag: from PySide2 import QtCore, QtGui, QtWidgets class StyledItemDelegate(QtWidgets.QStyledItemDelegate): def initStyleOption(self, option, index): option.state &= ~QtWidgets.QStyle.State_Selected super