pyside

QMimeData: setting and getting the right MIME types for arbitrary widgets

青春壹個敷衍的年華 提交于 2019-12-24 00:36:18
问题 Using PySide, I construct a draggable label that works exactly how I want: class DraggableLabel(QtGui.QLabel): def __init__(self, txt, parent): QtGui.QLabel.__init__(self, txt, parent) self.setStyleSheet("QLabel { background-color: rgb(255, 255, 0)}") def mouseMoveEvent(self, event): drag=QtGui.QDrag(self) dragMimeData=QtCore.QMimeData() drag.setMimeData(dragMimeData) drag.exec_(QtCore.Qt.MoveAction) (Note a full example that uses DraggableLabel is pasted below). Unfortunately, I do not

QImage from file content

我怕爱的太早我们不能终老 提交于 2019-12-24 00:04:59
问题 I have a table in my DB which contains information about images (like width, height, content-type, file-type and file content). In column file_content stored entire image (not pixel data or something else - entire file readed and stored as binary data). Now I want to create QImage (or QPixmap) from this record in my application on Python+PySide. How can I do it? I tried loadFromData, but it is expects raw pixel data, not file with header like in my case. Actually, I have no idea hot to solve

Warning seems to point to a different object address

拜拜、爱过 提交于 2019-12-23 23:39:45
问题 I'm using PySide and I get a warning when I try to set a spreadsheet to a certain widget: 09-18 14:48:54,107 WARNING [D=0x7ff4a0074650:qt] Could not parse stylesheet of widget 0x1cbecc0 I've pinpointed the location of the problem and fixed it, but I was surprised to see that the address of the object calling setStyleSheet() is different: <views.hierarchy.TreeView object at 0x7f3ab8139440> Ideally, when I get warnings like the above I wish I could dereference it like here and find out more

Python Qt bindings: setCosmetic() and sceneRect(), problems with margins

和自甴很熟 提交于 2019-12-23 20:25:50
问题 With the following simple example (which works well with either PySide or PyQt4): import sys import random import numpy from PySide import QtGui, QtCore class Window(QtGui.QWidget): def __init__(self): super(Window, self).__init__() self.resize(600, 400) self.view = QtGui.QGraphicsView() self.scene = QtGui.QGraphicsScene() self.view.setScene(self.scene) self.setWindowTitle('Example') # Layout layout = QtGui.QGridLayout() layout.addWidget(self.view, 0, 0) self.setLayout(layout) # Styles self

Pyside Changing Layouts

帅比萌擦擦* 提交于 2019-12-23 20:08:21
问题 I have a Interface that has 4 buttons across the top of the screen, and below that I have QFrame. I want to change the layout in the QFrame based on what button is pressed. For instance, if Button_1 is pressed show a TextEdit Widget, if Button_2 is pressed show a ListViewWidget. Does anyone have any idea on how this can be done? Thank You Very Much! 回答1: Use a QStackedLayout to store your widgets. Then you can change to the one with setCurrentIndex. Alternatively, you can use a QStackedWidget

PySide/PyQt: 'TypeError: native Qt signal is not callable' when trying to use 'currentItemChanged' with QTableWidget

浪尽此生 提交于 2019-12-23 19:15:15
问题 I have a table with some data that I want to be able to edit through the QTableWidget . Upon trying to connect the currentItemChanged signal: self.QTableWidget.currentItemChanged(QTableWidgetItem,QTableWidgetItem).connect(self.editCell) I get the following error: 'TypeError: native Qt signal is not callable' I went looking in to the QtDesigner , where you can connect signals. I made a QTableWidget , and connected it to a label so that changing the currentItem hid the label. In the signal

Qt Layouts for 3 panels, all vertically expanding to fill

∥☆過路亽.° 提交于 2019-12-23 19:04:28
问题 I am rather new to desktop GUI development. I am trying to get a frame with 3 parallel vertical panels, all expanding vertically to fill the window. I want the first two panels not to be flexible but to have a fixed size. Ex: Fixed W. |========| ############################ # # # # ^ #Fix.#Fix.# # | #|--|#|--|# <--Flexible--> # Flexible vertically all 3 panels. # # # # | # # # # v ############################ How can I obtain this layout? I am tried Grid, Vertical, Horizontal but I think I

How to provide data from PySide QAbstractItemModel subclass to QML ListView?

懵懂的女人 提交于 2019-12-23 16:53:53
问题 I have an app I'm writing in PySide that has a QML UI. I have subclassed QAbstractListModel in Python: class MyModel(QtCore.QAbstractListModel): def __init__(self, parent=None): QtCore.QAbstractListModel.__init__(self, parent) self._things = ["foo", "bar", "baz"] def rowCount(self, parent=QtCore.QModelIndex()): return len(self._things) def data(self, index, role=QtCore.Qt.DisplayRole): if role == QtCore.Qt.DisplayRole: return self._things[index.row()] return None I provide the model to my QML

How to detect dialog's close event?

萝らか妹 提交于 2019-12-23 14:57:51
问题 Hi everyone. I am making a GUI application using python3.4, PyQt5 in windows 7. Application is very sample. User clicks a main window's button, information dialog pops up. And when a user clicks information dialog's close button (window's X button), system shows confirm message. This is all. Here's my code. # coding: utf-8 import sys from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QDialog, QLabel class mainClass(QMainWindow): def __init__(self): super().__init__() self

PySide QThread.terminate() causing fatal python error

不打扰是莪最后的温柔 提交于 2019-12-23 13:13:35
问题 I am using PySide version 1.2.2, which wraps the Qt v4.8 framework. I am in a situation where I have to choose between having my application wait for a QThread that I no longer need to exit normally (it is quite possible that the thread will block indefinitely), and giving the unresponsive thread a grace period (of several seconds), then calling QThread.terminate() on it. Though I wish I could, I cannot let the QThread object go out of scope while the underlying thread is still running, since