QT之qss教程- QPushButton

官方參考資料:

http://doc.qt.io/qt-5.6/stylesheet-examples.html


QPushButton {
    /* 前景色 */
    color:red;

    /* 背景色 */
    background-color:rgb(30,75,10);

    /* 邊框風格 */
    border-style:outset;

    /* 邊框寬度 */
    border-width:2px;

    /* 邊框顏色 */
    border-color:rgb(10,45,110);

    /* 邊框倒角 */
    border-radius:10px;

    /* 字體 */
    font:bold 14px;

    /* 控件最小寬度 */
    min-width:100px;

    /* 控件最小高度 */
    min-height:20px;

    /* 內邊距 */
    padding:4px;
}

/* 鼠標按下時的效果 */
QPushButton#pushButton:pressed {
    /* 改變背景色 */
    background-color:rgb(40,85,20);

    /* 改變邊框風格 */
    border-style:inset;

    /* 使文字有一點移動 */
    padding-left:6px;
    padding-top:6px;
}

/* 按鈕樣式 */
QPushButton:flat {
	border:2px solid red;
}

/* 當按鈕打開菜單時:ui->pushButton->setMenu(btnMenu) */
QPushButton:open{
	background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #f6f7fa);
}

/* 子選擇器:菜單 */
QPushButton::menu-indicator {
	image:url(:/images/close.png);
	
	/* 去掉小三角號 
	image:none;*/
	
	/* 繪製subcontrol 的參考矩形的位置 */
	subcontrol-origin:padding;
	
	/* 小三角的位置 */
	subcontrol-position:bottom right;
}

QPushButton::menu-indicator:pressed,QPushButton::menu-indicator:open {
	position:relative;
	top:4px;
	left:4px;
}




發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章