How can I include the & character in a label. I've tried it, but it's not visible!
The first screenshot shows that I write the & character in the text field of a button. After confirming you can see screenshot 2. (I tried it in QT Designer)
This code example shows the problem:
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot
class App(QWidget):
def __init__(self):
super().__init__()
self.title = 'Keyboard'
self.setGeometry(10,10,320,320)
self.initUI()
def initUI(self):
self.setWindowTitle(self.title)
button = QPushButton('&', self)
button.move(100, 70)
button.released.connect(self.on_released)
self.show()
@pyqtSlot()
def on_released(self):
print('PyQt5 button click')
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = App()
sys.exit(app.exec_())