pyqt4

PyQt4 filter by text on a QListView using setRowHidden

烈酒焚心 提交于 2021-02-16 15:09:25
问题 I have a dialog which looks like this: That dialog has the following code connected to the filter button: class Dialog(QtGui.QDialog, addWin.Ui_Dialog): ... self.list = QListView() self.filter.clicked.connect(self.filterClicked) ... def filterClicked(self): filter_text = str(self.lineEdit.text()).lower() for row in range(self.model.rowCount()): if filter_text in str(self.model.item(row).text()).lower(): self.list.setRowHidden(row, True) else: self.list.setRowHidden(row, False) However, when I

PyQt4 filter by text on a QListView using setRowHidden

∥☆過路亽.° 提交于 2021-02-16 15:08:58
问题 I have a dialog which looks like this: That dialog has the following code connected to the filter button: class Dialog(QtGui.QDialog, addWin.Ui_Dialog): ... self.list = QListView() self.filter.clicked.connect(self.filterClicked) ... def filterClicked(self): filter_text = str(self.lineEdit.text()).lower() for row in range(self.model.rowCount()): if filter_text in str(self.model.item(row).text()).lower(): self.list.setRowHidden(row, True) else: self.list.setRowHidden(row, False) However, when I

KeyEvent in MainWindow (PyQt4)

[亡魂溺海] 提交于 2021-02-16 11:40:15
问题 I'm trying to to build a GUI with PyQt4 and control some actions with the arrow keys. Nevertheless I fail to get the keystrokes. It have to be a simple issue, but I newbie to this. So any help will be appreciated. Thanks! import sys from PyQt4 import QtCore, QtGui class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(910, 500) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8(

KeyEvent in MainWindow (PyQt4)

早过忘川 提交于 2021-02-16 11:36:15
问题 I'm trying to to build a GUI with PyQt4 and control some actions with the arrow keys. Nevertheless I fail to get the keystrokes. It have to be a simple issue, but I newbie to this. So any help will be appreciated. Thanks! import sys from PyQt4 import QtCore, QtGui class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(910, 500) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8(

KeyEvent in MainWindow (PyQt4)

时光总嘲笑我的痴心妄想 提交于 2021-02-16 11:35:34
问题 I'm trying to to build a GUI with PyQt4 and control some actions with the arrow keys. Nevertheless I fail to get the keystrokes. It have to be a simple issue, but I newbie to this. So any help will be appreciated. Thanks! import sys from PyQt4 import QtCore, QtGui class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(910, 500) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8(

QTreeView QAbstractItemModel parent collapses after deleting item and sometimes crashes

南笙酒味 提交于 2021-02-11 15:26:23
问题 Im trying to build a little list of entries within a QTreeView, and based on the example posted here, I got it to delete any child items via the right click context menu i added. but when i delete it the parent tree i have collapses. And in some cases if i delete a certain item in a certain order this crashes My understanding is that this is because upon deletion the indices of the items changes, and to prevent that QtCore.QPersistentModelIndex() can be utilized according to this thread: How

QTreeView QAbstractItemModel parent collapses after deleting item and sometimes crashes

牧云@^-^@ 提交于 2021-02-11 15:25:42
问题 Im trying to build a little list of entries within a QTreeView, and based on the example posted here, I got it to delete any child items via the right click context menu i added. but when i delete it the parent tree i have collapses. And in some cases if i delete a certain item in a certain order this crashes My understanding is that this is because upon deletion the indices of the items changes, and to prevent that QtCore.QPersistentModelIndex() can be utilized according to this thread: How

Trouble in retrieving window size and widget size

南笙酒味 提交于 2021-02-10 23:27:59
问题 Here is the code for a camera surveillance system. In the configuration_page.py file I'm getting the size of the window as 100x30 despite using self.showMaximized() and resizeEvent() . The widgets present in it are also showing the size as 640x480 . I'm particularly interested in retrieving the size of a widget named self.mid_frame in CameraDisplay class present in config.py file. Earlier I was facing the same issue in dashboard.py file but I found a workaround by explicitly passing width and

Printing QProcess Stdout only if it contains a Substring

夙愿已清 提交于 2021-02-10 16:01:36
问题 A PyQt4 app runs ping in a QProcess . A QTextEdit named self.output will output everything from ping . A second QTextEdit named self.summary will only output the line if it contains the string TTL . Problem: I have managed to get self.output working but not self.summary as I am not sure how to write its code in the dataReady function. Any ideas? import sys from PyQt4 import QtGui, QtCore class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.initUI()

Printing QProcess Stdout only if it contains a Substring

我只是一个虾纸丫 提交于 2021-02-10 16:00:40
问题 A PyQt4 app runs ping in a QProcess . A QTextEdit named self.output will output everything from ping . A second QTextEdit named self.summary will only output the line if it contains the string TTL . Problem: I have managed to get self.output working but not self.summary as I am not sure how to write its code in the dataReady function. Any ideas? import sys from PyQt4 import QtGui, QtCore class MainWindow(QtGui.QMainWindow): def __init__(self): super(MainWindow, self).__init__() self.initUI()