あなたは1つの...短い答えに丸めた質問のカップルを持って、はい、あなたはQTableWidgetにボタンを追加することができます
# initialize a table somehow
table = QTableWidget(parent)
table.setRowCount(1)
table.setColumnCount(1)
# create an cell widget
btn = QPushButton(table)
btn.setText('12/1/12')
table.setCellWidget(0, 0, btn)
をしかし、それはリットルを鳴らない: - あなたはsetCellWidgetを呼び出して、テーブルウィジェットに任意のウィジェットを追加することができますあなたが実際に欲しいものです。
ユーザーがボタンをクリックしたように、ダイアログやエディタなどを起動したように、セルのいずれかをダブルクリックすると反応するようです。
その場合は、あなたが本当にする必要があるすべてはそうのように、QTableWidgetからitemDoubleClicked信号に接続している:ユーザーが行をクリックしたときであるように、私は、行をすることができますどのように
def editItem(item):
print 'editing', item.text()
# initialize a table widget somehow
table = QTableWidget(parent)
table.setRowCount(1)
table.setColumnCount(1)
# create an item
item = QTableWidgetItem('12/1/12')
table.setItem(0, 0, item)
# if you don't want to allow in-table editing, either disable the table like:
table.setEditTriggers(QTableWidget.NoEditTriggers)
# or specifically for this item
item.setFlags(item.flags()^Qt.ItemIsEditable)
# create a connection to the double click event
table.itemDoubleClicked.connect(editItem)
個々のセルではなく強調表示されます。 –
do:table.setSelectionBehavior(QTableWidget.SelectRows) –
また、特定の行をクリックしたときに別のタブにリダイレクトできることはありますか?私の質問は、基本的に別のタブにリダイレクトすることができます、一種のハイパーリンクのようなhtmlのWebページです。 –