pyqt6

QFileDialog not closing after file selection

QFileDialog not closing after file selection Question: I have a simple function that opens a file dialog using pyqt6 to select a file. The function works, but the dialog hangs after being called and I’m not sure why it’s not getting automatically closed when the file is selected. def ui_find_file(title=None, initialdir=None, file_type=None): import os from …

Total answers: 1

PyQt6: Removing ALL padding around widget

PyQt6: Removing ALL padding around widget Question: I’m trying push two QLineEdit-widgets all the way up to each other, but no matter how and when i call setContentsMargins(0,0,0,0) , it just does not seem to remove all margins. I’ve tried googling, but all comments just say "use layout.setContentsMargins(0,0,0,0)", and that’s it. Can somebody explain to …

Total answers: 1

Play sound on button click in PyQt6

Play sound on button click in PyQt6 Question: I am trying to create 2 buttons that would play a sound once and endlessly. But at this stage it is not possible to reproduce the sound at all. What am I doing wrong? import sys from PyQt6.QtCore import QUrl from PyQt6.QtMultimedia import QMediaPlayer, QAudioOutput from PyQt6.QtWidgets …

Total answers: 1

Why do QGridLayout Widgets move around when adding new ones?

Why do QGridLayout Widgets move around when adding new ones? Question: I can’t seem to wrap my head around how they work. The the best for placing multiple widgets seems to be QGridLayout but when I add something into a specific row/column and later decide to add somthing into another row/column everything shifts and it’s …

Total answers: 1

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