pyside

pyside show / hide layouts

*爱你&永不变心* 提交于 2019-12-10 12:57:56
问题 I'm trying to display one of two layouts depending on whether a checkbox is checked or not. Only using widgets I can do the following which works fine: (each widget in this example is a QLineEdit) myCheckbox.stateChanged.connect(switchControls) def switchControls (self, state): if state == 2: self.widget1.show() self.widget2.hide() else: self.widget1.hide() self.widget2.show() However, since I want to add a descriptive label to each QLineEdit, I need to combine a QLineEdit+QLabel in a layout

pyside Get directory selected?

♀尐吖头ヾ 提交于 2019-12-10 12:17:21
问题 How can I get the directory selected from after the user selects it from the 'browse...' button? My goal is to make a folder get created in that directory using the name in the project field. This 'selecting of the directory' is the last part I need help figuring out. Thank you guys. import sys import os from PySide import QtGui class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): QtGui.QToolTip.setFont(QtGui.QFont('SansSerif', 10))

canFetchMore() and fetchMore() are not working as expected

99封情书 提交于 2019-12-10 11:18:16
问题 I have problems implementing Qt tree model with lazy loading using canFetchMore() and fetchMore() . I have this code: from PySide.QtCore import Qt, QAbstractItemModel, QModelIndex from PySide.QtWidgets import QTreeView, QApplication BATCH_SIZE = 100 class ObjectItem(object): def __init__(self, parent, name, data, row): self.parent = parent self.name = name self.data = data self.row = row self.hasChildren = False self.canFetchMore = False # ints have no children if isinstance(data, int):

Refresh view when model data has not changed (Qt/PySide/PyQt)?

守給你的承諾、 提交于 2019-12-10 10:36:15
问题 I have a tree view of a standard item model in which I can use a spinbox to change the row height in the view (see SSCCE below). This doesn't change the content of the view, only its appearance, sort of like resizing the main window except I have to do it myself: I change the row height from within the delegate's sizeHint method. It is within sizeHint that I get the value from the spinbox and set the row height to that value. To make sure the size hint is actually called, I refresh the view

Wrapping C++ Qt widget for using in Python with PySide

时光怂恿深爱的人放手 提交于 2019-12-10 10:29:04
问题 What is the best approach for wrapping a custom C++ library with custom Qt display widgets in Python for using in a PySide based QApplication? Does the C++ library need special treatment for wrapping with SWIG? Will wrapped Qt widgets integrate properly with PySide? I would appreciate any comments on the appropriate nomenclature needed to refine my unsuccessful searches on this subject. 回答1: The Shiboken bindings tool used to generate the PySide bindings for Qt turns out to be the right tool

Correctly Installing and configuring Python/Pyside/PyDev on OS X Lion (and likely future versions of OS X)

眉间皱痕 提交于 2019-12-10 09:27:56
问题 I am having issues with PyDev not auto completing pyside correctly, I suspect that I am missing a crucial step in the installation process. So, How does one install and configure a fresh OS X lion install to develop pyside ? Note: This Question does NOT belong on another stack site. This is what a programmer has to do to get his machine in shape to develop python PySide using PyDev. A system administrator is unlikely to have encountered this specific issue. 回答1: I suspect you followed the

Elegant command line argument parsing for PyQt

戏子无情 提交于 2019-12-10 02:48:17
问题 I'm writing a new PyQt app. I'm trying to do everything related to the program and ui using as much of the PyQt APIs as possible as a means to improve my knowledge of PyQt and Qt in general. The question I have is, is there an API within PyQt/Qt to handle command line argument parsing elegantly? My research so far has turned up: an example of how to make it play nice with python's opt_parser module, except it doesn't handle QApplication's built in arg parsing. PyKDE's KCmdLineArgs (which

PySide: QTreeView to nested dictionary

此生再无相见时 提交于 2019-12-09 23:08:08
问题 I need help to build a hierarchical nested dict from a QTreeView structure to get something like this: {"A": {"B": {"H": {}, "I": {"M": {}, "N": {}}}, "D": {}, "E": {}, "F": {}, "G": {"L": {}}, "C": {"J": {}, "K": {}}}} { "A": { "B": { "H": {}, "I": { "M": {}, "N": {} } }, "D": {}, "E": {}, "F": {}, "G": { "L": {} }, "C": { "J": {}, "K": {} } } } I am not using columns in this case and the QTreeView represents a directory structure (i actually extracted it from a dict like tho one above and

setItemWidget causing crash

99封情书 提交于 2019-12-09 19:00:49
问题 I'm trying to add a QLabel to a QTreeWidgetItem but Python crashes on the setItemWidget call. Any ideas why it crashes? Here is the code: from PySide import QtCore, QtGui view = QtGui.QTreeWidget() view.show() newItem = QtGui.QTreeWidgetItem(view) view.setItemWidget(newItem,0,QtGui.QLabel('abc')) 回答1: You need to keep a reference to the label, or give it a parent: view.setItemWidget(newItem, 0, QtGui.QLabel('abc', view)) 来源: https://stackoverflow.com/questions/27644304/setitemwidget-causing

Virtual column in QTableView?

梦想的初衷 提交于 2019-12-09 17:50:29
问题 I'm started to learning Qt4 Model/View Programming and I have beginner question. I have simple application which show sqlite table in QTableView : class Model(QtSql.QSqlTableModel): def __init__(self, parent=None): super(Model, self).__init__(parent) self.setEditStrategy(QtSql.QSqlTableModel.OnFieldChange) self.setTable("test") self.select() class App(QtGui.QMainWindow): def __init__(self, model): QtGui.QMainWindow.__init__(self) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui