Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7820345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:15:37+00:00 2026-06-02T07:15:37+00:00

Firstly, I’m new to Python, Qt and PySide so forgive me if this question

  • 0

Firstly, I’m new to Python, Qt and PySide so forgive me if this question seems too simple.

What I’m trying to do is to display a bunch of photos in a grid in a GUI constructed using PySide API. Further, when a user clicks on a photo, I want to be able to display the information corresponding to that photo. Additionally, I would like the container/widget used for displaying the photo to allow for the photo to be changed e.g. I should be able to replace any photo in the grid without causing the entire grid of photos to be created from scratch again.

Initially I tried to use QLabel to display a QPixmap but I realized (whether mistakenly or not) that I have no way to detect mouse clicks on the label. After some searching, I got the impression that I should subclass QLabel (or some other relevant class) and somehow override QWidget’s(QLabel’s parent class) mousePressEvent() to enable mouse click detection. Problem is I’m not sure how to do that or whether there is any alternative widget I can use to contain my photos other than the QLabel without having to go through subclass customization.

Can anyone suggest a more suitable container other than QLabel to display photos while allowing me to detect mouse clicks on the photo or provide some code snippet for subclassing QLabel to enable it to detect mouse clicks?

Thanks in advance for any replies.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:15:39+00:00Added an answer on June 2, 2026 at 7:15 am

    I’ve added an example of how to emit a signal and connect to another slot. Also the docs are very helpful

    from PySide.QtCore import *
    from PySide.QtGui import *
    
    import sys
    
    
    class Main(QWidget):
    
    
        def __init__(self, parent=None):
            super(Main, self).__init__(parent)
    
            layout  = QHBoxLayout(self)
    
            picture = PictureLabel("pic.png", self)
            picture.pictureClicked.connect(self.anotherSlot)
    
            layout.addWidget(picture)
            layout.addWidget(QLabel("click on the picture"))
    
        def anotherSlot(self, passed):
            print passed
            print "now I'm in Main.anotherSlot"
    
    
    class PictureLabel(QLabel):
    
        pictureClicked = Signal(str) # can be other types (list, dict, object...)
    
        def __init__(self, image, parent=None):
            super(PictureLabel, self).__init__(parent)        
            self.setPixmap(image)
    
        def mousePressEvent(self, event):
            print "from PictureLabel.mousePressEvent"
            self.pictureClicked.emit("emit the signal")
    
    a = QApplication([])
    m = Main()
    m.show()
    sys.exit(a.exec_())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly I realise that this is a familiar question, it seems to pop up
Firstly, I apologise if this is a really simple question to those with more
Firstly, I do not have any malicious intent out of this question. I would
Firstly, this is a homework assignment, and I am very new to programming in
Firstly, please forgive me if I have asked this before (i suffer memory problems
Firstly, as this is essentially a multi-disciplinary question, please feel free to submit answers
Firstly, this seems like something that should have been asked before, but I cannot
Firstly, I want to restrict this question to web development only. So this is
Firstly, this question is similar to How to re-save the entity as another row
Firstly, this is not a question about repository synchronisation for which there are numerous

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.