pyqt6

PyQt6 – custom widget – get default widget colors for text, background etc

PyQt6 – custom widget – get default widget colors for text, background etc Question: I’m developing custom components using PyQt6. I now like to adapt my widgets’ colors to the default Palette colors so that they look like the default widgets of PyQt6. I think I found a way to get the default colors of …

Total answers: 1

In Python PyQt6, Why is my QTreeView displaying white icons instead of folder icons from QStandardItemModel?

In Python PyQt6, Why is my QTreeView displaying white icons instead of folder icons from QStandardItemModel? Question: I am attempting to add a folder icon for the folder items in my directory, along with the icons for the associated file type. iconProvider = QFileIconProvider() for item in os.listdir(path): QItem = QStandardItem(item) file_item_icon = iconProvider.icon(QFileInfo(item)) QItem.setIcon(file_item_icon) …

Total answers: 1

How to get feedback from ComboBoxes created in a loop

How to get feedback from ComboBoxes created in a loop Question: I am trying to feed an unspecified number of comboboxes to a user. Once the user selects inputs for the combo boxes I want to be able to print out those combobox inputs after the submit button is clicked. Currently I can only print …

Total answers: 1

PyQt QTableView resizeRowsToContents not completely resize on initialisation

PyQt QTableView resizeRowsToContents not completely resize on initialisation Question: I have a minimum example here of a QTableView widget that displays a long string that I want word wrapped when I start the app. from PyQt6.QtWidgets import ( QMainWindow, QTableView, QHeaderView, QApplication, ) from PyQt6.QtCore import ( Qt, QEvent, QAbstractTableModel, QSize, QEvent ) import sys …

Total answers: 1

PYQT6.4 QTableWidget.sortItems function, Pycharm is throwing a syntax issue even though syntax follows documentation

PYQT6.4 QTableWidget.sortItems function, Pycharm is throwing a syntax issue even though syntax follows documentation Question: Here is the documentation: QTableWidget.sortItems This is the function: PySide6.QtWidgets.QTableWidget.sortItems(column[, order=Qt.AscendingOrder]) The following is my code: self.notes_current_table_widget.sortItems(column[2, order=Qt.AscendingOrder]) PyCharm displays this as an error, when I try to run I get: SyntaxError: invalid syntax. Maybe you meant ‘==’ or ‘:=’ …

Total answers: 1

Unable to click, select or move QGraphicsEllipseItem

Unable to click, select or move QGraphicsEllipseItem Question: A small snippet I am using to understand QGraphicsEllipseItem. From my understanding , based on the flags set I should be able to move and capture mouse events but am unable to do so. Any help or guidance ? import sys from PySide6.QtCore import QPoint, QRectF from …

Total answers: 1

How to call a QTextEdit widget from MainWindow and use it from another class? [pyqt5, pyside, python]

How to populate a QTextEdit, that is inside a QTabWidget, by opening a text file? [pyqt5, python] Question: I am trying to use the self.textedit = qtw.QTextEdit() widget that I declared from my MainWindow into my TextFileOpenedInNewTab class by doing this self.main_window = MainWindow() and using it like this self.main_window.textedit.setPlainText(content). It works, but it has …

Total answers: 2

PySide6 app crashes when using QPainter.drawLine()

PySide6 app crashes when using QPainter.drawLine() Question: On Windows 10, python3.10, PySide6 (or PyQt6) QApplication crashes when calling QPainter.drawLine() . The terminal just displays : Process finished with exit code -1073741819 (0xC0000005) Please find below the code: import sys from PySide6.QtCore import QPoint, Qt from PySide6.QtGui import QColor, QPainter, QPen, QPixmap from PySide6.QtWidgets import QApplication, …

Total answers: 1