How do I get the font size and color of the text in the tooltip to change from that of the button? It keeps displaying as the size/font of the pushbutton instead of it's own. Also how do I get the text "leave the program" to actually fit in the tooltip?
I've tried this method and couldn't get it to work: Setting the text colour of a tooltip in PyQt
import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.resize(100, 100)
self.setWindowTitle("Example")
self.leave = QPushButton("X", self)
self.leave.setStyleSheet("background-color : grey ; color : red ; font: 20pt")
self.leave.setToolTip("Leave the Program")
self.setStyleSheet("QToolTip{background-color : blue ; color: k ; font: 12pt}")
self.leave.move(38, 25)
self.leave.resize(24, 50)
self.leave.clicked.connect(self.exit)
def exit(self):
app.quit()
if __name__ == '__main__':
app = QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())