PtQt5 not displaying TIF file

Hi there, I am a beginner in GUI formation with PyQt 5. The thing is I have some raster files that I want to display in my GUI, though the code is not giving any error but still its not displaying my file as well. I am trying to display it in QGraphicsView(I don’t know if its the right way to display or not).My GUI displays multiple things like a matrix and some txt result and check buttons to switch on an off the raster files. But I don’t know how to o it an I’m stuck at first step now. Please help me out! :slight_smile:

and the code is

import sys
import rasterio
from PyQt5 import QtWidgets, uic
from PyQt5.QtGui import QImage, QPixmap
from rasterio.plot import show

class FinalApp(QtWidgets.QMainWindow):
    def __init__(self):
        uic.loadUi("Final.ui", self)

    def display_tiff(self):
        file_path = 'C:\\Users\\Hp\\Downloads\\Geology_img.tif' # Provide the path to your TIFF file
            # Open the TIFF file
            raster =

            # Convert raster image to QImage
            img =[1, 2, 0])  # Read the raster data
            q_img = QImage(, img.shape[1], img.shape[0], img.shape[1] * 3, QImage.Format_RGB888)

            # Convert QImage to QPixmap
            pixmap = QPixmap.fromImage(q_img)

            # Display the QPixmap in the QGraphicsView
            scene = QtWidgets.QGraphicsScene()

        except Exception as e:
            print(f"Error processing {file_path}: {e}")

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = FinalApp()