2023年10月31日,周二晚上
#include <QGridLayout>
#include <QPushButton>
#include <QLabel>
#include <QApplication>
#include <QStyle>int main(int argc, char *argv[])
{QApplication a(argc, argv);QWidget widget;widget.setWindowTitle("QGridLayout网格布局和Qt内置标签");int iconID=0;QGridLayout *layout = new QGridLayout;for(int i=0;i<10;i++){for(int j=0;j<10;j++){QPushButton *button=new QPushButton(QString::number(iconID));button->setIcon(widget.style()->standardIcon(static_cast<QStyle::StandardPixmap>(iconID)));layout->addWidget(button,i,j);iconID++;}}widget.setLayout(layout);widget.show();return a.exec();
}