from PyQt5 import uic, QtWidgets
from PyQt5.QtWidgets import *
from functools import partial
from PyQt5.QtCore import *
import sys
import json
class Exampleforstack(QMainWindow):
def __init__(self):
super(Exampleforstack, self).__init__()
uic.loadUi('mainui.ui', self)
#label_6 is Qlabel
self.label_6.setText('we have an <a href = "self.GetNews">important message</a> for you!')
self.label_6.setTextFormat(Qt.RichText)
self.label_6.setTextInteractionFlags(Qt.TextBrowserInteraction)
self.label_6.setOpenExternalLinks(True)
def GetNews(self, event):
self.stackedWidget.setCurrentIndex(0)
if __name__ == '__main__':
app = QApplication(sys.argv)
widget = QtWidgets.QStackedWidget()
mainWindow = Exampleforstack()
widget.addWidget(mainWindow)
main = Exampleforstack()
widget.show()
widget.showFullScreen()
app.exec_()
Is there any way make hyperlink linking inner function? I wanna make program when i click this hyperlink i get result of method self.GetNews. i think HTML is the most useful way since i want to make qlabel like this
i think this cause because of my lack html knowledge. searched lot but currently not get what i want
Is there any possible way i can do this? or similar way (i can make whole qlabel clickable but that is not i want)