sql - PyQt Get cell from TableView with header label -


i load results of sql query tableview.

self.projectmodel = qsqlquerymodel() self.projectmodel.setquery(sql,db) 

i need select specific cell based on header label (geometry). column move position depending on different table search.

when user clicks anywhere on row (not cell of geometry column) select geometry column cell.

at moment have associated tableview

self.dlg.tableview.clicked.connect(self.cellclicked) 

and in function have

row = self.projectmodel.currentindex() 

if use qtableview.model(row, column) select index, have speciify row , column number. however, vary want qtableview.model(row, 'geometry') model expects integers.

any solutions?

thanks

so seems need method find column header label, i.e. like:

def columnfromlabel(self, label):     model = self.table.horizontalheader().model()     column in range(model.columncount()):         if model.headerdata(column, qtcore.qt.horizontal) == label:             return column     return -1 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -