//設定按鈕樣式
static qstring setpushbuttonqss(qpushbutton *btn, //按鈕物件
int radius = 5, //圓角半徑
int padding = 8, //間距
const qstring &normalcolor = "#34495e", //正常顏色
const qstring &normaltextcolor = "#ffffff", //文字顏色
const qstring &hovercolor = "#4e6d8c", //懸停顏色
const qstring &hovertextcolor = "#f0f0f0", //懸停文字顏色
const qstring &pressedcolor = "#2d3e50", //按下顏色
const qstring &pressedtextcolor = "#b8c6d1"); //按下文字顏色
//設定文字框樣式
static qstring setlineeditqss(qlineedit *txt, //文字框物件
int radius = 3, //圓角半徑
int borderwidth = 2, //邊框大小
const qstring &normalcolor = "#dce4ec", //正常顏色
const qstring &focuscolor = "#34495e"); //選中顏色
//設定進度條樣式
static qstring setprogressbarqss(qprogressbar *bar,
int barheight = 8, //進度條高度
int barradius = 5, //進度條半徑
int fontsize = 9, //文字字型大小
const qstring &normalcolor = "#e8edf2", //正常顏色
const qstring &chunkcolor = "#e74c3c"); //進度顏色
//設定滑塊條樣式
static qstring setsliderqss(qslider *slider, //滑動條物件
int sliderheight = 8, //滑動條高度
const qstring &normalcolor = "#e8edf2", //正常顏色
const qstring &groovecolor = "#1abc9c", //滑塊顏色
const qstring &handlebordercolor = "#1abc9c", //指示器邊框顏色
const qstring &handlecolor = "#ffffff", //指示器顏色
const qstring &textcolor = "#000000"); //文字顏色
//設定單選框樣式
static qstring setradiobuttonqss(qradiobutton *rbtn, //單選框物件
int indicatorradius = 8, //指示器圓角角度
const qstring &normalcolor = "#d7dbde", //正常顏色
const qstring &checkcolor = "#34495e"); //選中顏色
//設定滾動條樣式
static qstring setscrollbarqss(qwidget *scroll, //滾動條物件
int radius = 6, //圓角角度
int min = 120, //指示器最小長度
int max = 12, //滾動條最大長度
const qstring &bgcolor = "#606060", //背景色
const qstring &handlenormalcolor = "#34495e", //指示器正常顏色
const qstring &handlehovercolor = "#1abc9c", //指示器懸停顏色
const qstring &handlepressedcolor = "#e74c3c"); //指示器按下顏色
qstring quihelper::setpushbuttonqss(qpushbutton *btn, int radius, int padding,
const qstring &normalcolor,
const qstring &normaltextcolor,
const qstring &hovercolor,
const qstring &hovertextcolor,
const qstring &pressedcolor,
const qstring &pressedtextcolor)
qstring quihelper::setlineeditqss(qlineedit *txt, int radius, int borderwidth,
const qstring &normalcolor,
const qstring &focuscolor)
qstring quihelper::setprogressbarqss(qprogressbar *bar, int barheight,
int barradius, int fontsize,
const qstring &normalcolor,
const qstring &chunkcolor)
qstring quihelper::setsliderqss(qslider *slider, int sliderheight,
const qstring &normalcolor,
const qstring &groovecolor,
const qstring &handlebordercolor,
const qstring &handlecolor,
const qstring &textcolor)
") .arg(handlecolor).arg(handlebordercolor).arg(handlewidth).arg(handleoffset).arg(handleradius));
//偏移乙個畫素
handlewidth = handlesize + sliderheight / 5;
.arg(normalcolor).arg(sliderheight).arg(sliderradius));
.arg(groovecolor).arg(sliderheight).arg(sliderradius));
.arg(normalcolor).arg(sliderheight).arg(sliderradius));
"background:qradialgradient(spread:pad,cx:0.5,cy:0.5,radius:0.5,fx:0.5,fy:0.5,stop:0.6 %1,stop:0.8 %2);}")
.arg(handlecolor).arg(handlebordercolor).arg(handlewidth).arg(handleoffset).arg(handleradius));
qstring qss = list.join("");
slider->setstylesheet(qss);
return qss;
}qstring quihelper::setradiobuttonqss(qradiobutton *rbtn, int indicatorradius,
const qstring &normalcolor,
const qstring &checkcolor)
").arg(normalcolor));
"stop:0 %1,stop:0.3 %1,stop:0.4 #ffffff,stop:0.6 #ffffff,stop:0.7 %1);}").arg(checkcolor));
qstring qss = list.join("");
rbtn->setstylesheet(qss);
return qss;
}qstring quihelper::setscrollbarqss(qwidget *scroll, int radius, int min, int max,
const qstring &bgcolor,
const qstring &handlenormalcolor,
const qstring &handlehovercolor,
const qstring &handlepressedcolor)
Qt通用方法及類庫6
判斷是否是ip位址 static bool isip const qstring ip 判斷是否是mac位址 static bool ismac const qstring mac 判斷是否是合法的 號碼 static bool istel const qstring tel 判斷是否是合法的郵箱位...
Qt通用方法及類庫11
static bool iplive const qstring ip,int port,int timeout 1000 獲取網頁所有源 static qstring gethtml const qstring url 獲取本機公網ip位址 static qstring getnetip cons...
Qt通用方法及類庫8
異或加密演算法 static qstring getxorencryptdecrypt const qstring str,char key 異或校驗 static uchar getorcode const qbytearray data 計算校驗碼 static uchar getcheckco...