命令链接按钮QCommandLinkButton

继承QPushButton   

它的用途类似于单选按钮的用途,因为它用于在一组互斥选项之间进行选择,命令链接按钮不应单独使用,而应作为向导和对话框中单选按钮的替代选项,外观通常类似于平面按钮的外观,但除了普通按钮文本之外,它还允许描述性文本

创建命令链接按钮

QCommandLinkBut​​ton(parent)

QCommandLinkBut​​ton(text, parent)

QCommandLinkBut​​ton(text, description ,parent)

#description-描述

from PyQt5.QtWidgets import QApplication, QWidget,QCommandLinkButton
import sys
from PyQt5.QtGui import QIcon

class win(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(300,300)
        self.setWindowTitle('右击菜单')
        btn1=QCommandLinkButton('上一页','描述',self)
        btn1.move(100,50)
        btn1.setDescription('描述1')   #设置描述
        btn1.setIcon(QIcon('大象.png'))    #设置图标


if __name__=='__main__':
    app=QApplication(sys.argv)
    w=win()
    w.show()
    sys.exit(app.exec_())

description()     获取描述

效果图

天子骄龙

原文地址:https://www.cnblogs.com/liming19680104/p/10770993.html