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 7507093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:25:01+00:00 2026-05-29T22:25:01+00:00

Whenever I click any function in the list widget, it ran a specific function.

  • 0

Whenever I click any function in the list widget, it ran a specific function. Now I want to send the item itself, as a parameter to that function. Here is the code:

QtCore.QObject.connect(self.listWidget, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.test)

def test(self):
    print 'hello'

Instead I want:

def test(self,item):
        print item
  • 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-05-29T22:25:02+00:00Added an answer on May 29, 2026 at 10:25 pm

    That should already work – when itemClicked is emitted it sends the clicked QListWidgetItem as a parameter. You just need to edit your test function to accept an extra parameter, and that will be your QListWidgetItem.

    from PyQt4.QtCore import QCoreApplication, Qt
    from PyQt4.QtGui import QListWidget, QListWidgetItem, QApplication
    
    import sys
    
    class MyList(QListWidget):
        def __init__(self):
            QListWidget.__init__(self)
            self.add_items()
            self.itemClicked.connect(self.item_click)
    
        def add_items(self):
            for item_text in ['item1', 'item2', 'item3']:
                item = QListWidgetItem(item_text)
                self.addItem(item)
    
        def item_click(self, item):
            print item, str(item.text())
    
    if __name__ == '__main__':
        app = QApplication([])
        myList = MyList()
        myList.show()
        sys.exit(app.exec_())
    

    In the above example you’ll see a QListWidget with three items. When you click an item the item along with the item’s text will be printed to the console.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to change the incremental for hour and minute, by whenever click on
I have create a widget in android , whenever i click on Widget TextView
I recently updated my Eclipse (now running 20100218-1602), and I've found whenever I click
Is there ASP button that won't submit post form data. Whenever I click an
i wanted to reload an element whenever there is a click event on any
I am using datatables in my application. Whenever user click on any row I
I want to have a list of links, that each open a different Youtube
I have this simple html piece of code, whenever I click on any of
I want to create a hyperlink that does not link to any page. When
I'm working on a form that calls a function whenever the value of a

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.