当我尝试打印我的QtableWidget的索引时,奇怪的输出?

时间:2017-08-04 15:17:22

标签: python object pyqt5 qtablewidget

背景资讯

我创建了一个名为self.TableOBJ的QtableWidget实例,但我无法从中引用信息。

现在我试图选择给定整数的相应行,但是当我这样做并尝试打印我的行时它返回none。

这让我相信我引用的对象是不正确的。

所以我试图访问我的QtableWidget的垂直索引,看看我是否可以获得任何输出,但是当我这样做时它返回以下内容......

<PyQt5.QtCore.QModelIndex object at 0x00000000047BC5F8>

问题

任何人都可以解释为什么输出采用这种格式以及如何将其转换为实际的索引列表?

如果有人能帮助我选择我的QtableWidget那一行也会有所帮助。

def initiateMultiPlot(self, tableV, rowV, PlotV):
    """
        1. Match TableName values with the key values in our TableDB
        2. When we find a  match look at that key's corresponding Table Object, and iterate
        through that objects rows and select the rows specified by rowV
        3.Call plot for those values

    """
    f = createFIG()
    print("")
    for i in tableV:
        """
            tableV: is list of strings that represent assigned tablenames [Table1, Table2, Table3]
            rowV: is a list, containing lists representing rows from corresponding Tables the user wishes to plot.
                for example [[1,2],[3,4],[1]] means rows 1,2 from table1, rows 3,4 from table2... so on
            PlotV: is a string that is ethier "box" or "whisker" to tell what method to plot. Default right now 
            is to do a simple boxplot
        """
        print("Creating table instance")

        #Table Dictionary is setup so the names of the Tables (tableV) are the keys of the dictionary
        # and the actual table objects are referenced by these keys
        self.TableOBJ = self.TableDictionary[i]
        print("Data Type for the table object is..................{}".format(type(self.TableOBJ)))

        #for i in range(self.TableOBJ.rowCount()):
        # try:
        #     self.TableOBJ.setVerticalHeaderLabels(arange(self.TableOBJ.rowCount()))
        # except Exception as e:
        #     print(e)


        ### Test to see if I can print any output from my object###

        print((self.TableOBJ.currentIndex()))
        for j in rowV:
              for k in j:
                print("selecting rows")
                print(self.TableOBJ.selectRow(k))

                x = self.TableOBJ.selectRow(k)
                print("x data is here before plot command is issued................... {}".format(x))
                #ColHeader is the horizontal header for my QtableWidget, and is just a list of strings.
                y = self.TableOBJ.ColHeader
                f.plotData(x,y,PlotV, False)


    f.plt.show()

完整代码:https://github.com/Silvuurleaf/Data-Analysis-and-Visualization-GUI/blob/master/Plotter4.1

问题源于我的班级MainWindow

中的第299行

用于上传数据的文件:https://github.com/Silvuurleaf/Data-Analysis-and-Visualization-GUI/blob/master/Test%206.csv

0 个答案:

没有答案