views:

220

answers:

2

Hi everyone,

i'm trying to realize non-editable QTableView with widgets in cells that should contain clickable listed text. With following code i'm setting widget in definite cell:

view = QTableView()
label = QLabel( <some html text> )
...
view.setIndexWidget(index, label)

I used html to make label's text clickable, but links became blue with underline and moreover by clicking on it with right mouse button appears popup menu with "Copy Link Locaion" option, where i wanted to place some hidden information instead of url and of course do not let user see this info.

I'm looking for light-weight widget, i thought that insertion of QGraphicsView in each cell will lead to big computer loads, but can't think of any other solution.

Can you advice what should i use for this purpose?

Thank you in advance

Serge

+1  A: 

Use the QTextBrowser widget instead of QLabel.

Patrice Bernassola
A: 

I get myself confused when i saw in documentation supported tags, that haven't even tried to check styles supporting in QLabel. So I've solved it with following:

self.setContextMenuPolicy(Qt.PreventContextMenu)
...
str = "<qt><style>a.class1 { color: black; text-decoration: none; }</style>"
str += "<a href='" + <hiden_value> + "' class='class1'>" + <value> + "</a>" 
serge