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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:44:54+00:00 2026-06-18T00:44:54+00:00

I am making a stock control program and i have hit a problem with

  • 0

I am making a stock control program and i have hit a problem with getting the value of a selected cell, i know i need to use “QtGui.QTableWidget.currentRow” and “QtGui.QTableWidget.currentColumn” to get the item’s position. However i cannot seem to get this to work because when the functions are called nothing has been selected and so it returns -1,-1

Does anyone know how to get it so it runs the “QtGui.QTableWidget.currentRow” and “QtGui.QTableWidget.currentColumn” everytime the user selects a cell?

i think the code i need to get the actual data once i have the co-ords is QtGui.QTableWidget.item ?

This is the code i am using to get the row and column:

row = self.table.currentRow
column = self.table.currentColumn
self.ID = self.table.item(row, column)

when the user clicks a button to add stock the program should then use the product code it will have just got to make the change to the database after getting the quantity added from the user

I am using python 3.2 and pyqt 4

any help would be appreciated

Thank you

Sam

  • 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-18T00:44:55+00:00Added an answer on June 18, 2026 at 12:44 am

    When the QTableWidget sees that someone has clicked one of it’s cells, it will emit a cellClicked event – which you need to connect to. Maybe something like

    self.table.cellClicked.connect(self.cell_was_clicked)
    

    could be in your setup code,
    and the function cell_was_clicked might be something like

    def cell_was_clicked(self, row, column):
        print("Row %d and Column %d was clicked" % (row, column))
        item = self.table.itemAt(row, column)
        self.ID = item.text()
    

    I’ve not used currentRow and currentColumn as you want a response on the click. This function is documented here (sorry, I prefer pyside – it’s pretty much the same as PyQT). Note also itemAt instead of just item – as you will get the item at the cell, not it’s contents. Use the .text() function of QTableWidgetItem to get at the contents.

    Note – this is using ‘slots and signals’ and in particular the ‘new style’. As you’re using PyQT4 and Python 3 you should have no trouble with ‘new stuff’ 🙂

    You might consider browsing a slots and signals tutorial – that might straighten a few of these abstract concepts out. Good luck!

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

Sidebar

Related Questions

So I'm making a very small program for personal use in tkinter, and I've
Making a word document of our network set-up. We have about 7 servers and
My wife recently started a business making soap bars and the soap labels have
I'm making a table with data, and the last column needs to be have
hello I am very beginer of haskell I am making GUI program that open
I have the following definition at the top of my .ASCX file: <%@ Control
I am making a simple program in visual c# 2005 that looks up a
Say that I have a UIView which I would like to re-use in multiple
I am making an application to control the mouse using an analog stick from
I've been making my first ASP.NET Visual Studio website and I have just started

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.