SaiyanElite
SaiyanElite

Reputation: 139

Link QTableWidget cells to webpages

I was wondering if it is possible to double click on a cell in a QTableWidget (I've already disabled cell editing) and it opening a link in a web browser. I'm using PyQt4 for Python 3.4.2.

Upvotes: 3

Views: 3615

Answers (2)

SaiyanElite
SaiyanElite

Reputation: 139

self.tableWidget.itemDoubleClicked.connect(self.OpenLink)

def OpenLink(self,item):
    if item.column() == 1:
        webbrowser.open('www.google.com')

This is how I solved it in my program, item.text() is the text in the cell, item.row() is it's row number and item.column() the column number.

Upvotes: 10

NoDataDumpNoContribution
NoDataDumpNoContribution

Reputation: 10860

Sure it is possible. You just need to combine two things.

Connect a suitable slot to signal cellDoubleClicked of QTableWidget.

Tell a browser to display a link using the webbrowser module of Python.

Upvotes: 1

Related Questions