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
Forum Updated to NodeBB v4.3 + New Features

Pop up window showing image

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 3 Posters 2.2k 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 24 Aug 2021, 17:08 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?

    E 1 Reply Last reply 24 Aug 2021, 19:52
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 Aug 2021, 17:11 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 24 Aug 2021, 18:29 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
          24 Aug 2021, 17:08

          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?

          E Offline
          E Offline
          eyllanesc
          wrote on 24 Aug 2021, 19:52 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

          1/4

          24 Aug 2021, 17:08

          • Login

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