Qt内置了一些图标,一共有71个(Qt 5.9.8),不同的平台下图标有所差异。
在Qt助手索引中输入QStyle::StandardPixmap即可查看详细描述。
官方文档中只有描述没有图示,现通过一个小Demo将所有图标展示如下:
关键代码如下:
QGridLayout *layout = ui->gridLayout;
int IconIndex = 0;
for (int row = 0; row <= 7; row++){
for (int col = 0; col < 10; col++){
enum QStyle::StandardPixmap Icon = (enum QStyle::StandardPixmap)IconIndex;
layout->addWidget(new QPushButton(QApplication::style()->standardIcon(Icon), QString::number(IconIndex)), row, col);
IconIndex++;
}
}