pyside

QLayout: Attempting to add QLayout “” to QWidget “”, which already has a layout

余生颓废 提交于 2019-11-28 22:32:35
问题 I want to create some tabs, and I read this answer: How to add a tab in PySide I use the code in the answer and made some changes. Cause my code has to read some files and get the name of my tabs from those file, so that I add a for loop in my code. And here is my code. from PySide import QtCore, QtGui import sys import dflash_controller as con if __name__ == "__main__": list = [['a', 3], ['b', 4], ['c', 5], ['d', 6]] app = QtGui.QApplication(sys.argv) wid = QtGui.QWidget() grid = QtGui

PySide - PyQt : How to make set QTableWidget column width as proportion of the available space?

孤者浪人 提交于 2019-11-28 22:24:52
问题 I'm developing a computer application with PySide and I'm using the QTableWidget. Let's say my table has 3 columns, but the data they contain is very different, like (for each row) a long sentence in the first column, then 3-digit numbers in the two last columns. I'd like to have my table resize in order to adjust its size to the data , or at least to be able to set the column sizes as (say) 70/15/15 % of the available space . What is the best way to do this ? I've tried table

Displaying LaTeX in pyQt/pySide QTableWidget

若如初见. 提交于 2019-11-28 22:06:59
I would like to add mathematical expressions to the table labels (e.g.: 2^3 should be properly formatted) Here is a simple example of a table: http://thomas-cokelaer.info/blog/2012/10/pyqt4-example-of-tablewidget-usage/ setHorizontalHeaderLabels accepts string, only. I wonder if is it possible to implement somehow this matplotlib approach: matplotlib - write TeX on Qt form are there other options? I've also been trying for some time to display complex labels in the header of a QTableWidget . I was able to do it by reimplementing the paintSection method of a QHeaderView and painting manually

Is the PySide Slot Decorator Necessary?

蹲街弑〆低调 提交于 2019-11-28 17:14:47
I've seen some example code for PySide slots that uses the @QtCore.Slot decorator, and some that does not. Testing it myself, it doesn't seem to make a difference. Is there a reason I should or should not use it? For example, in the following code: import sys from PySide import QtCore # the next line seems to make no difference @QtCore.Slot() def a_slot(s): print s class SomeClass(QtCore.QObject): happened = QtCore.Signal(str) def __init__(self): QtCore.QObject.__init__(self) def do_signal(self): self.happened.emit("Hi.") sc = SomeClass() sc.happened.connect(a_slot) sc.do_signal() the @QtCore

Loading QtDesigner's .ui files in PySide

耗尽温柔 提交于 2019-11-28 15:59:45
问题 I am looking for a simple example of how to directly load a QtDesigner generated .ui file into a Python application. I simply would like to avoid using pyuic4. 回答1: PySide, unlike PyQt, has implemented the QUiLoader class to directly read in .ui files. From the linked documentation, loader = QUiLoader() file = QFile(":/forms/myform.ui") file.open(QFile.ReadOnly) myWidget = loader.load(file, self) file.close() 回答2: For the complete noobs at PySide and .ui files, here is a complete example:

MVC design with Qt Designer and PyQt / PySide

北城余情 提交于 2019-11-28 14:52:13
问题 Python newbie coming from Java (+SWT/Windowbuilder) and am having difficulty working out how to properly code a large desktop app in Python/Qt4(QtDesigner)/PySide. I would like to keep any view logic in a controller class outside the .ui file (and it's .py conversion). Firstly as then the logic is independent of GUI framework and secondly as the .ui and resultant .py file get overwritten on any changes!. Only examples I've found add action code to a monolithic MainWindow.py (generated from ui

How to get text from a QLineEdit dynamically? [closed]

自作多情 提交于 2019-11-28 14:51:07
How could get String(Text) from QlineEdit ? I tried Like this. myArea.getList() function is get string value and check database with string value and return List self.a = QLineEdit() self.b = QlineEdit() .... self.b = self.myArea.getList(str(self.a.textChanged.connect(self.textchanged))) def textchanged(self, text): self.my_edit = text Input text in a , then a changes. read a , check data by a , b 's data created, Input text in b , read b , check data by b First, I don't know how to get QLineEdit() 's value. print QLineEdit Text works but return String. Here is a complete example how to get

How to distinguish between mouseReleaseEvent and mousedoubleClickEvent on QGraphicsScene

笑着哭i 提交于 2019-11-28 14:39:02
I am overriden QGraphicsScene and overload 2 methods: mouseDoubleClickEvent and mouseReleaseEvent . I want different logic executing on each of this event, but I do not know how to distinguish it? At least 1 mouseReleaseEvent occured before mouseDoubleClickEvent . Cory Klein For the logic that you want to occur on a double click, put the code inside mouseDoubleClickEvent() and for the logic that you want to occur on a mouse release, put the code inside mouseReleaseEvent() . If you want to do something when the user clicks but doesn't double click, you have to wait to see if they click twice or

How to drop a custom QStandardItem into a QListView

孤街浪徒 提交于 2019-11-28 14:06:17
I am trying to get drag&drop to work between two QListViews using a custom QStandardItem. I can't find the info I need online other than this document which helped a little bit but now I'm stuck. Drag&drop from one QListView to another works fine when I use a QStandardItem to hold my data, but when I use a custom item I run into trouble, because the receiving model/view creates a QStandardItem when a custom item is dropped. Ideally I could tell the receiving model to use my custom item as the default item and otherwise just do it's thing, but I suppose it won't be that easy?! It seems that

How to know if object gets deleted in Python

核能气质少年 提交于 2019-11-28 13:51:54
I have an object in the heap and a reference to it. There are certain circumstances in which the object gets deleted but the reference that points to its location doesn't know that. How can I check if there is real data in the heap? For example: from PySide import * a = QProgressBar() b = QProgressBar() self.setIndexWidget(index,a) self.setIndexWidget(index,b) Then the a object gets deleted but print(a) returns a valid address. However if you try a.value() - runtime error occurs (C++ object already deleted). a is None returns False . use sip module, read more about sip here import sip a =