def initUI(self): qbtn = QPushButton('Quit', self) qbtn.clicked.connect(QApplication.instance().quit) qbtn.resize(qbtn.sizeHint()) qbtn.move(50, 50) self.setGeometry(300, 300, 350, 250) self.setWindowTitle('Quit button') self.show()
class TableHeaderView(QHeaderView): def __init__(self, orientation, parent, title): """ Custom QHeaderView that shows how to add buttons to the header view """ super().__init__(orientation, parent) # Create the buttons that will be added to the table headers self.add_row_button = QPushButton("+", self) # Use the sizeHint() values to determine the height and width # of all of the buttons height = self.add_row_button.sizeHint().height() width = self.add_row_button.sizeHint().width() + 10 self.add_row_button.setGeometry(self.offset() + 5, 0, width, height) self.add_row_button.clicked.connect(parent.addRowToTable) self.delete_row_button = QPushButton("-", self) self.delete_row_button.setGeometry(self.offset() + width + 5, 0, width, height) self.delete_row_button.clicked.connect(parent.deleteRowFromTable) self.clear_rows_button = QPushButton("Clear", self) self.clear_rows_button.setGeometry(self.offset() + width * 2 + 5, 0, width, height) self.clear_rows_button.clicked.connect(parent.clearRowsFromTable)
def initUI(self): QToolTip.setFont(QFont('SansSerif', 10)) self.setToolTip('This is a <b>QWidget</b> widget') btn = QPushButton('Button', self) btn.setToolTip('This is a <b>QPushButton</b> widget') btn.resize(btn.sizeHint()) btn.move(50, 50) self.setGeometry(300, 300, 300, 200) self.setWindowTitle('Tooltips') self.show()