QMenu自定義icon大小

2021-10-10 19:30:53 字數 1058 閱讀 9704

qmenu預設的icon最大是16px*16px,而且通過stylesheet還改不了。

問題癥結:qmenu 使用 qproxystyle 裡面的qstyle::pm_smalliconsize

解決辦法: 1.定義乙個新的style繼承自qproxystyle 替換掉qstyle::pm_smalliconsize

標頭檔案:

#include

class

customiconstyle

:public qproxystyle

;#endif

// customiconstyle_h

原始檔:

#include

"customiconstyle.h"

customiconstyle::

customiconstyle()

customiconstyle::

~customiconstyle()

void customiconstyle::

setcustomsize

(int nsize )

int customiconstyle::

pixelmetric

( pixelmetric metric,

const qstyleoption * option,

const qwidget * widget )

const

return s;

}

使用時:

customiconstyle* pstyle =

new customiconstyle;

m_logomenu-

>

setstyle

(pstyle)

; m_logomenu-

>

setstylesheet

(

實測這樣不會覆蓋stylesheet中的樣式(hover效果)。在qt5下若直接繼承qcommonstyle可能發生menu開啟一片空白,或者無hover效果。

vue使用自定義的icon

首先因為elementui提供的icon太少了,所有自己找找有沒有向量圖可以引入。推薦使用阿里爸爸向量圖示管理,iconfont 登入賬號,找到需要的圖示加入購物車 然後新增到專案 開啟html檔案,有使用方法教程 第一步 在index.html引入fontclass 第二步 挑選相應圖示並獲取類名...

vant step步驟條自定義icon

近期使用vant 框架,需要用到步驟條的元件,但是在官網上查詢api,只提供了啟用和未啟用的狀態,但是有的業務場景 待審核 審核通過 審核未通過 完成 如果使用多種狀態,就需要使用插槽v slot,但是官網只提供了api並未提示案例寫法 先一步一步來,按照官網實現乙個簡化版 第一種 vant官網的例...

scrollview自定義分頁大小

cgpoint nearesttargetoffsetforoffset cgpoint offset withvelocity cgpoint velocity cgfloat pagesize self.cellwidth self.padding cgfloat targetx cgfloat...