pyqt5

Plot image at center of label in PyQT

Plot image at center of label in PyQT Question: QGridLayout is used to place QLabel. Then cv2 images are displayed as follows. frame = self.dequeList[cam.camID].popleft() img = QtGui.QImage(frame, frame.shape[1], frame.shape[0], QtGui.QImage.Format_RGB888).rgbSwapped() pix = QtGui.QPixmap.fromImage(img) self.videoList[f"video_{cam.camID}"].setPixmap(pix) Now display start from 0,0 coordinates as below. I like to display image at the center of label. How can …

Total answers: 1

Search (position) in two-dimensional List

Search (position) in two-dimensional List Question: There is a list: Aliances=[(1, ‘Star Aliance’), (2, ‘OneWorld’), (3, ‘SkyTeam’), (4, ‘Unknown’), (5, ‘U-FLY Alliance’), (6, ‘SkyTeam Cargo’), (7, ‘WOW’), (8, ‘Vanilla Alliance’), (9, ‘Value Alliance’), (10, ‘American Eagle’), (11, ‘American Airlines’), (12, ‘Sirius Aero’), (10012, ‘ASL Aviation Holdings DAC’)] There is a number that is on this …

Total answers: 1

PyQt readyRead: set text from serial to multiple labels

PyQt readyRead: set text from serial to multiple labels Question: In PyQt5, I want to read my serial port after writing (requesting a value) to it. I’ve got it working using readyRead.connect(self.readingReady), but then I’m limited to outputting to only one text field. The code for requesting parameters sends a string to the serial port. …

Total answers: 2

QTreeWidget clear empty space at the bottom of widget

QTreeWidget clear empty space at the bottom of widget Question: Is this example i have a QTreeWidget with 4 columns. The last column is filled by QFrames. File ui.py from PyQt5 import QtCore, QtGui, QtWidgets import sys if __name__ == "__main__": app = QtWidgets.QApplication(sys.argv) app.setStyle("Windows") treeWidget = QtWidgets.QTreeWidget() treeWidget.headerItem().setText(0, "Α/Α") treeWidget.headerItem().setText(1,"Τύπος") treeWidget.headerItem().setText(2,"Τίτλος") treeWidget.headerItem().setText(3,"Προεπισκόπιση") treeWidget.setStyleSheet("QTreeWidget::item{height:60px;}") l …

Total answers: 1

Why can't I sort columns in my PyQt5 QTableWidget using UserRole data?

Why can't I sort columns in my PyQt5 QTableWidget using UserRole data? Question: I am trying to sort my QTableWidget columns by the values stored in the user role of each QTableWidgetItem, but I am unable to do so. I have enabled sorting with self.setSortingEnabled(True), and I have set the data in each QTableWidgetItem with …

Total answers: 2

QAxWidget glitches when resizing GUI window

QAxWidget glitches when resizing GUI window Question: I am currently exploring the possibilities of displaying and working with PowerPoint presentations in a GUI using PyQt5/PyQt6 and Python. For that I found the most promising solution to be using a QAxWidget. Loading and displaying the pptx-file works fine, but unfortunately I noticed glitches when resizing the …

Total answers: 1

Read "date" from table

Read "date" from table Question: In my GUI, made with Qt Designer, I have table, 6 columns and 5 rows(headers not count). In first column will be date in format "DD/MM/YY". How I can read and save to some variable those dates, for future use in pdf report? Dates will not be used in any …

Total answers: 1

Pyside/Pyqt5 dynamically adding and sorting items

Pyside/Pyqt5 dynamically adding and sorting items Question: I have a simple user interface where I want to dynamically add frames and labels in a widget (as I will use these labels to transmit a video feed from my webcams). In the following code I set a function where the user selects an integer which represents …

Total answers: 2

Qt QProgressBar not updating regularly when text is not visible

Qt QProgressBar not updating regularly when text is not visible Question: I have a QProgressBar that is set to not display text. It appears that this causes the progress bar to not update regularly, but only after some chunks (roughly 5-10%). The following minimum Python example shows a window with two progress bars which get …

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