Error QAbstractTableModel (parent: QObject = None): argument 1 has unexpected type 'list'

0

I'm learning Python. I work in Win8.1 with Python 3.7.

I must create a qtableview to show 9 columns of read-only data. Send as a parameter a list like the following:

xlista = ['ars 1', 'Ars-s 2', 'Bry 2', 'CALC 3', 'cean 1', 'coll 1', 'cupr 1', 'dam 1', 'dros 1 ']

The string number is variable.

This list is sent as a parameter to my assignedRemediosTable (xlist) function:

defRemediosTable (xlist):

this Qtableview has 9 columns:

header = ['col_0', 'col_1', 'col_2', 'col_3', 'col_4', 'col_5', 'col_6', 'col_7', 'col_8']         print (xlista)         tablemodel = MyTableModel (xlista, header)         self.TableList ofRemedios.setModel (tablemodel)

class MyTableModel (QAbstractTableModel):

def __init__(self,  datain, parent=None, *args):
    QAbstractTableModel.__init__(self, datain,  parent, *args)
    self.arraydata = datain

I get the error:

QAbstractTableModel (parent: QObject = None): argument 1 has unexpected type 'list'

I wonder where I have the error. On the other hand, I wonder if there is an easier way to assign the model to the qtableview. I do not know if instead of the list you can do something like:

tablemodel = QStandardItemModel (9, 7)

Thanks for your help.

    
asked by Alejandro Fernandez 18.11.2018 в 18:58
source

0 answers