Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Pop up window showing image
Qt 6.11 is out! See what's new in the release blog

Pop up window showing image

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 3 Posters 3.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john_hobbyist
    wrote on last edited by
    #1

    Hello, I have built an application with GUI on PyQt5. I need to display pop up window when press a button. This pop up window should show image. How can I achieve that? From a little google search I see that pop up windows show only text... Is there any other class suitable for what I want to achieve?

    eyllanescE 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Create a QDialog based class that will show the image. You can use a QLabel to show it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • J Offline
        J Offline
        john_hobbyist
        wrote on last edited by john_hobbyist
        #3

        At that part:

        https://www.tutorialspoint.com/pyqt/pyqt_qdialog_class.htm

        I connect the window() method to the pressed button of the central GUI right instead of calling it at the end, right?

        1 Reply Last reply
        0
        • J john_hobbyist

          Hello, I have built an application with GUI on PyQt5. I need to display pop up window when press a button. This pop up window should show image. How can I achieve that? From a little google search I see that pop up windows show only text... Is there any other class suitable for what I want to achieve?

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by
          #4

          @john_hobbyist Demo:

          from PyQt5 import QtGui, QtWidgets
          
          
          def handle_clicked():
              dialog = QtWidgets.QDialog()
              lay = QtWidgets.QVBoxLayout(dialog)
              label = QtWidgets.QLabel()
              lay.addWidget(label)
              pixmap = QtGui.QPixmap("/path/of/image")
              label.setPixmap(pixmap)
              dialog.exec_()
          
          
          def main():
              app = QtWidgets.QApplication([])
          
              w = QtWidgets.QPushButton("Press me")
              w.clicked.connect(handle_clicked)
              # w.resize(640, 480)
              w.show()
          
              app.exec_()
          
          
          if __name__ == "__main__":
              main()
          

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved