QFileDialog - How to load and display image in a QLabel
-
Hi
How to load and display an image in a QLabel using QFileDialog. The image paths is working perfectly but after selecting the image, the page exits. The image should display after it is selected.from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication, QLabel, QFileDialog from PyQt5.QtGui import QPixmap self.ui.Display_Button.clicked.connect(self.Load_Display) def Load_Display(self): fname = QFileDialog.getOpenFileName(self, "Choose File", "", "All FIles(*) ;; Images(*.jpeg)") pixmap = QPixmap(fname) self.ui.Display_label.setPixmap(QPixmap(pixmap)) self.ui.Display_label.repaint()
-
Hi
How to load and display an image in a QLabel using QFileDialog. The image paths is working perfectly but after selecting the image, the page exits. The image should display after it is selected.from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication, QLabel, QFileDialog from PyQt5.QtGui import QPixmap self.ui.Display_Button.clicked.connect(self.Load_Display) def Load_Display(self): fname = QFileDialog.getOpenFileName(self, "Choose File", "", "All FIles(*) ;; Images(*.jpeg)") pixmap = QPixmap(fname) self.ui.Display_label.setPixmap(QPixmap(pixmap)) self.ui.Display_label.repaint()
-
@eyllanesc Thanks it worked!. I have a question if you could please assist, I'm using QDateEdit to Popup a calender when the QDateEdit is clicked. Below is what I did but its not working.
from PyQt5 import QtCore, QtGui, QtWidgets from datetime import datetime import sys self.dateedit = QtWidgets.QDateEdit(calendarPopup=True) self.dateedit.setDateTime(QtCore.QDateTime.currentDateTime())
-
@eyllanesc Thanks it worked!. I have a question if you could please assist, I'm using QDateEdit to Popup a calender when the QDateEdit is clicked. Below is what I did but its not working.
from PyQt5 import QtCore, QtGui, QtWidgets from datetime import datetime import sys self.dateedit = QtWidgets.QDateEdit(calendarPopup=True) self.dateedit.setDateTime(QtCore.QDateTime.currentDateTime())
@LT-K101 said in QFileDialog - How to load and display image in a QLabel:
but its not working
You have to set https://doc.qt.io/qt-5/qdatetimeedit.html#calendarPopup-prop if you want a pop-up...
-
@LT-K101 said in QFileDialog - How to load and display image in a QLabel:
but its not working
You have to set https://doc.qt.io/qt-5/qdatetimeedit.html#calendarPopup-prop if you want a pop-up...