Why am I unable to correctly retrieve and use a QTableWidgetItem?
<p>I looked up the documentation for creating QTableWidgetItems, and it says that I need to use the <code>item()</code> method. 
"Returns the item for the given row and column if one has been set; otherwise returns 0."
Here is how I used it:</p>

<p><code>self.table.item(item.row(),1)</code></p>

<p>There definitely is an item at these values.
<code>item.row()</code> is the row associated with an item in the same row I am trying to return. everything about that item is working fine, and <code>.text()</code> returns the correct information. I got that item by using
<code>self.table.itemChanged.connect(self.log_change)</code></p>

<p>for some reason it is just this item that I am trying to return that doesn't work. when I go <code>print(self.table.item(item.row(),1).text())</code>
it prints nothing, just an empty string. The value it should print is <code>int(0)</code></p>

<p>surrounding with <code>int()</code> doesn't work.</p>

<p>Is there some way I can select or return the item at that row and column, and have <code>.text()</code> give the <code>int(0)</code> that is in there as a result?
Why would it just be printing an empty string when the QTableWidget shows the number 0?</p>

<p>Edit:</p>

<pre><code>    self.cur.execute("""SELECT s.StudentID, s.FullName, m.PreviouslyMailed, m.nextMail, m.learnersDate, m.RestrictedDate, m.DefensiveDate FROM
                        StudentProfile s LEFT JOIN Mailouts m ON s.studentID=m.studentID""")
    self.all_data = self.cur.fetchall()
    self.search_results()

    self.table.setRowCount(len(self.all_data))
    self.tableFields = ["Check","REMOVE THIS","Full name","Previously mailed?","Next mail","learners date","Restricted date","Defensive driving date"]
    self.columnList = ["StudentID","FullName","PreviouslyMailed","NextMail","learnersDate","RestrictedDate","DefensiveDate"]
    self.table.setColumnCount(len(self.tableFields))
    self.table.setHorizontalHeaderLabels(self.tableFields)
    self.checkbox_list = []
    for i, item in enumerate(self.all_data):
        FullName = QtGui.QTableWidgetItem(str(item[1]))
        PreviouslyMailed = QtGui.QComboBox()
        PreviouslyMailed_combobox_list = ["No", "Yes"]
        PreviouslyMailed.addItems(PreviouslyMailed_combobox_list)
        LearnersDate = QtGui.QTableWidgetItem(str(item[4]))
        RestrictedDate = QtGui.QTableWidgetItem(str(item[5]))
        DefensiveDate = QtGui.QTableWidgetItem(str(item[6]))
        NextMail = QtGui.QTableWidgetItem(str(item[3]))
        StudentID = QtGui.QTableWidgetItem(item[0])
        self.table.setItem(i, 1, StudentID)
        self.table.setItem(i, 2, FullName)
        self.table.setCellWidget(i, 3, PreviouslyMailed)
        self.table.setItem(i, 4, LearnersDate)
        self.table.setItem(i, 5, RestrictedDate)
        self.table.setItem(i, 6, DefensiveDate)
        self.table.setItem(i, 7, NextMail)
        chkBoxItem = QtGui.QTableWidgetItem()
        chkBoxItem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
        chkBoxItem.setCheckState(QtCore.Qt.Unchecked)
        self.checkbox_list.append(chkBoxItem)
        self.table.setItem(i, 0, self.checkbox_list[i])
        FullName.setFlags(FullName.flags() &amp; ~Qt.ItemIsEditable)
        NextMail.setFlags(NextMail.flags() &amp; ~Qt.ItemIsEditable)
    self.table.blockSignals(False)
    self.changed_items = []
    self.table.itemChanged.connect(self.log_change)

def log_change(self, item):
    self.table.blockSignals(False)
    self.changed_items.append((self.table.itemAt(item.row(),1),item))

def click_btn_edit(self):
    print("Updating")
    IDList = []
    for item in self.changed_items:
        text, col, row = item[1].text(), item[1].column(), item[1].row()
        new_data = self.all_data
        IDvar = item[0].text()
        #IDvar prints as an empty string.
        IDList.append(IDvar)
</code></pre>

<p>second edit:</p>

<pre><code>import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import *
import sqlite3
from datetime import datetime
import calendar
import sip
sip.setapi('QVariant', 2)


class WindowContainer():
    def __init__(self):
        self.windows = []


def _fromUtf8(t):
    return t

class mainWindowTemplate(QMainWindow):

    def __init__(self):

        super().__init__()
        self.initUI()

    def initUI(self):
        self.setObjectName(_fromUtf8("mainWindowTemplate"))
        self.resize(800, 600)
        self.centralwidget = QtGui.QWidget(self)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.gridLayout = QtGui.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))

        self.table = QtGui.QTableWidget(self.centralwidget)
        self.table.setObjectName(_fromUtf8("table"))
        self.table.setColumnCount(0)
        self.table.setRowCount(0)
        self.gridLayout.addWidget(self.table, 0, 0, 1, 1)

        self.btn_edit = QtGui.QPushButton(self.centralwidget)
        self.btn_edit.setObjectName(_fromUtf8("btn_edit"))
        self.gridLayout.addWidget(self.btn_edit, 1, 0, 1, 1)
        self.setCentralWidget(self.centralwidget)
        self.btn_edit.clicked.connect(self.click_btn_edit)

        self.menubar = QtGui.QMenuBar(self)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        self.setMenuBar(self.menubar)

        """self.statusbar = QtGui.QStatusBar(self)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        self.setStatusBar(self.statusbar)"""

        self.setWindowTitle("MainWindow")
        self.btn_edit.setText("Edit")

        self.conn = sqlite3.connect("EDA_Database.db")
        self.cur = self.conn.cursor()

        QtCore.QMetaObject.connectSlotsByName(self)
        self.show()
        self.click_btn_mailingInfo()


    def retranslateUi(self):

        self.setWindowTitle(_translate("MainWindow", "MainWindow", None))

    def click_btn_mailingInfo(self):
        self.table.blockSignals(True)
        self.screen_name = "mailingInfo"
        self.cur.execute("""SELECT s.StudentID, s.FullName,     m.PreviouslyMailed, m.nextMail, m.learnersDate, m.RestrictedDate, m.DefensiveDate FROM
                        StudentProfile s LEFT JOIN Mailouts m ON s.studentID=m.studentID""")
        self.all_data = self.cur.fetchall()

        self.table.setRowCount(len(self.all_data))
        self.tableFields = ["Check","If you see this column, an error has occured.","Full name","Previously mailed?","Next mail","learners date","Restricted date","Defensive driving date"]
        self.columnList = ["StudentID","FullName","PreviouslyMailed","NextMail","learnersDate","RestrictedDate","DefensiveDate"]
        self.table.setColumnCount(len(self.tableFields))
        self.table.setHorizontalHeaderLabels(self.tableFields)
        self.checkbox_list = []
        for i, item in enumerate(self.all_data):
            FullName = QtGui.QTableWidgetItem(str(item[1]))
            PreviouslyMailed = QtGui.QComboBox()
            PreviouslyMailed_combobox_list = ["No", "Yes"]
            PreviouslyMailed.addItems(PreviouslyMailed_combobox_list)
            LearnersDate = QtGui.QTableWidgetItem(str(item[4]))
            RestrictedDate = QtGui.QTableWidgetItem(str(item[5]))
            DefensiveDate = QtGui.QTableWidgetItem(str(item[6]))
            NextMail = QtGui.QTableWidgetItem(str(item[3]))
            StudentID = QtGui.QTableWidgetItem(str(item[0]))
            self.table.setItem(i, 1, StudentID)
            self.table.setItem(i, 2, FullName)
            self.table.setCellWidget(i, 3, PreviouslyMailed)
            self.table.setItem(i, 4, LearnersDate)
            self.table.setItem(i, 5, RestrictedDate)
            self.table.setItem(i, 6, DefensiveDate)
            self.table.setItem(i, 7, NextMail)
            chkBoxItem = QtGui.QTableWidgetItem()
            chkBoxItem.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled)
            chkBoxItem.setCheckState(QtCore.Qt.Unchecked)
            self.checkbox_list.append(chkBoxItem)
            self.table.setItem(i, 0, self.checkbox_list[i])
            FullName.setFlags(FullName.flags() &amp; ~Qt.ItemIsEditable)
            NextMail.setFlags(NextMail.flags() &amp; ~Qt.ItemIsEditable)
        self.table.setColumnHidden(1, True)
        self.table.blockSignals(False)
        self.changed_items = []
        self.combobox_item_list = []
        self.table.itemChanged.connect(self.log_change)
        #PreviouslyMailed.currentIndexChanged.connect(self.comboBox_change(None,None,row,1,self.table.cellWidget(row,1).currentText()))

    def log_change(self, item):
        self.table.blockSignals(False)
        self.changed_items.append((self.table.item(item.row(),1),item))

    def click_btn_edit(self):
        IDList = []
        for item in self.changed_items:
            text, col, row = item[1].text(), item[1].column(), item[1].row()
            new_data = self.all_data
            IDvar = item[0].text()

            #no longer works
            print(text)

            #now works
            print(IDvar)

            IDList.append(IDvar)

if __name__ == "__main__":
    container = WindowContainer()
    app = QApplication(sys.argv)
    container.windows.append(mainWindowTemplate())
    sys.exit(app.exec_())
</code></pre>

<p>If you look at the qt docs for QTableWidgetItem, you will see that it can only be constructed from another item, from a string, from an icon and a string, or from an integer representing the type id of the item. You are giving the constructor the student ID directly, so it is using that last constructor, which creates an empty item. So,  use this:</p>

<pre><code>StudentID = QtGui.QTableWidgetItem(str(item[0])) 
</code></pre>

<p>Once that is fixed,  you still have the issue that you are connecting to the table itemChanged signal in click_btn_mailingInfo. Verify that this function is only called once (in particular disable line for us to connection s by name to see if it makes a difference). </p>

python pyqt