qt QSS样式使用方法
头文件添加:
private: Ui::MainWindow *ui; QFile *qssFile; int id1,id2,id3;
构造函数中:
qssFile= new QFile(":/new/qss/aa.qss",this); qssFile->open(QFile::ReadOnly); QString style_sheet=QString(qssFile->readAll()); qApp->setStyleSheet(style_sheet); qssFile->close();
添加资源文件方法:
aa.qss
QMainWindow { border-image:url(:/new/image/imgs/p3.png); } QPushButton { background-color:rgba(100,225,100,120); border-style:outset; border-width:4px; border-radius:10px; border-color:rgba(255,255,255,30); font:bold 18px;XX color:rgba(255,255,255,0); padding:6px; } QPushButton:hover { background-color:rgba(100,255,100,100); border-color:rgba(225,225,225,200); color:rgba(0,0,0,100); } QPushButton:pressed { background-color:rgba(100,255,100,200); border-color:rgba(255,255,255,30); border-style:inset; color:rgba(0,0,0,100); } QSlider::handle:horizontal { image:url(:/image/sliderHandle.png); } QSlider::sub-page:horizontal { border-image:url(:/image/slider.png); }
欢迎讨论,相互学习。
cdtxw@foxmail.com