pyside

How can I highlight a full row of text in a QPlainTextEdit widget?

How can I highlight a full row of text in a QPlainTextEdit widget? Question: I’ve made a little editor using a QPlainTextEdit and I’d like to be able to highlight a whole row of text to show which line has an error on. I can format the text, but I can’t work out how to …

Total answers: 1

Make QTableView editable when model is pandas dataframe

Make QTableView editable when model is pandas dataframe Question: In my gui file I create a QTableView as follows (this is the part that is automatically generated by Qt Designer): self.pnl_results = QtGui.QTableView(self.tab_3) font = QtGui.QFont() font.setPointSize(7) self.pnl_results.setFont(font) self.pnl_results.setFrameShape(QtGui.QFrame.StyledPanel) self.pnl_results.setFrameShadow(QtGui.QFrame.Sunken) self.pnl_results.setEditTriggers(QtGui.QAbstractItemView.AllEditTriggers) self.pnl_results.setShowGrid(True) self.pnl_results.setSortingEnabled(True) self.pnl_results.setCornerButtonEnabled(True) self.pnl_results.setObjectName(“pnl_results”) I then define a model that enables me to link …

Total answers: 2

PySide application crashes when setting a new widget to QScrollArea

PySide application crashes when setting a new widget to QScrollArea Question: This is a simplification of an application I wrote. The application’s main window has a button and a checkbox. The checkbox resides inside a QScrollArea (via a widget). The checkbox has a number stating how many times that checkbox was created. Clicking on the …

Total answers: 1

PySide – QStackedLayout.setCurrentIndex() does not work as expected when it's inside a for-loop

PySide – QStackedLayout.setCurrentIndex() does not work as expected when it's inside a for-loop Question: I’m implementing a UI, which it contains several buttons on top, and there’s a QStackedLayout object under those buttons, the purpose of clicking on different buttons should automatically switch to its associated QWidget, which is inside the QStackedLayout object. And the …

Total answers: 1

How to round QWidget corners

How to round QWidget corners Question: I wonder if there is there a way to round Qt widget corners? from PyQt4 import QtCore, QtGui class Custom(QtGui.QWidget): def __init__(self, *args, **kwargs): QtGui.QWidget.__init__(self, *args, **kwargs) self.setWindowOpacity(0.9) self.setWindowFlags(QtCore.Qt.Popup|QtCore.Qt.FramelessWindowHint) self.setWindowTitle(‘Custom’) self.resize(440,220) self.move(QtGui.QCursor.pos()) def closeEvent(self, event): event.accept() sys.exit(app.exec_()) def mousePressEvent(self, event): self.close() if __name__ == “__main__”: app = QtGui.QApplication(sys.argv) w …

Total answers: 3

QtConcurrent in PySide/PyQt

QtConcurrent in PySide/PyQt Question: I’m trying to figure out if subclassing QtConcurrent and writing a run method inside it will work: class Task(QtCore.QtConcurrent): def run(self, function): function() Or is it completely useless? Asked By: Elteroooo || Source Answers: It’s completely useless, because QtConcurrent is a namespace, not a class. Also, neither PyQt nor PySide provide …

Total answers: 3

How do I load children from .ui file in PySide?

How do I load children from .ui file in PySide? Question: For now I’m loading them like this: if __name__ == ‘__main__’: app = QApplication(sys.argv) loader = QUiLoader() file = QFile(‘main.ui’) file.open(QFile.ReadOnly) window = loader.load(file) file.close() window.show() # Here: window.centralwidget.findChild(QListWidget, ‘listWidget’).addItems([‘Item {0}’.format(x) for x in range(100)]) sys.exit(app.exec_()) But I think it’s uncomfortably, is there any …

Total answers: 1

MVC design with Qt Designer and PyQt / PySide

MVC design with Qt Designer and PyQt / PySide Question: 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 …

Total answers: 1

How can I intercept when a widget loses its focus

How can I intercept when a widget loses its focus Question: I have a QPlainTextEdit and want to process the content when it loses focus. I’ve seen that I can either do this with the focusChanged event or with the focusOutEvent virtual function. I don’t know how to pass parameters with the new syntax (i.e. …

Total answers: 1