目标:只使用CSS的方式,展示每种控件的可美化内容和细节。
文中使用的CSS样式都是通过如下代码的方式加载到窗口中,文件以UTF-8进行存储。
QDir::setCurrent(QApplication::applicationDirPath()); QByteArraybCSS; QFilefCSS("skin.css"); if(fCSS.open(QIODevice::ReadOnly)){ bCSS=fCSS.readAll(); fCSS.close(); } this->setStyleSheet(QString::fromUtf8(bCSS)); |
因为文章太长,上传到文档中提供下载链接: http://download.csdn.net/detail/bbdxf/9875760
下面是目录:
前言......................................................................................................................................................... 2
1. Button篇............................................................................................................................................... 2
1.1 QPushButton................................................................................................................................. 2
1.2 QToolButton.................................................................................................................................. 3
1.3 QRadioButton................................................................................................................................ 4
1.4 QCheckBox.................................................................................................................................... 5
2. Item篇.................................................................................................................................................. 6
2.1 QListWidget(等同QListView).......................................................................................................... 6
2.2 QTreeWidget(等同QTreeView)........................................................................................................ 7
2.3 QTableWidget(等同QTableView)..................................................................................................... 9
3. Container篇.......................................................................................................................................... 9
3.1 QGroupBox................................................................................................................................... 9
3.2 QTabWidget................................................................................................................................. 10
3.3 QTabBar...................................................................................................................................... 13
3.4 QToolBox..................................................................................................................................... 13
3.5 QDockWidget............................................................................................................................... 14
4. InputWidget篇..................................................................................................................................... 15
4.1 QLineEdit..................................................................................................................................... 15
4.2 QTextEdit..................................................................................................................................... 16
4.3 QComboBox................................................................................................................................ 16
4.4 QSpinBox(同QTimeEdit,QDateTimeEdit).................................................................................... 17
4.5 QScrollBar(包含水平和垂直).................................................................................................... 18
4.6 QSlider(包含水平和垂直)........................................................................................................ 20
5. DisplayWidget篇.................................................................................................................................. 21
5.1 QLabel(类似QFrame).............................................................................................................. 21
5.2 QProgressBar............................................................................................................................... 21
5.4 其他展示控件............................................................................................................................ 22
6. 其他重要控件..................................................................................................................................... 22
6.1 QMenu....................................................................................................................................... 22
6.2 QHeaderView.............................................................................................................................. 24
6.3 QAbstractScrollArea...................................................................................................................... 25
6.4 属性列表................................................................................................................................... 25
6.5 伪状态列表................................................................................................................................ 39
7. 异型控件............................................................................................................................................ 41
7.1 不规则图标按钮......................................................................................................................... 41
7.2 异形窗口................................................................................................................................... 41
7.3 设置背景图片 42CSDN的上传功能太垃圾了,我试了5、6次,换了兼容模式才成功~