Movie Example
tips1:.h中包含Qt类
QT_BEGIN_NAMESPACE
class QCheckBox;
class QGridLayout;
class QHBoxLayout;
QT_END_NAMESPACE
tips2:gif自适应窗口setScaledContents
void MoviePlayer::fitToWindow()
{
movieLabel->setScaledContents(fitCheckBox->isChecked());
}
tips2:QStyle::StandardPixmap自带图标集
Qt帮助里只提供列表,没有图标集,这里写一个demo用于显示(win7下)
关键代码如下:
QGridLayout *layout = qobject_cast<QGridLayout *>(ui->centralWidget->layout());//默认没有layout()
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++;
}
}
enum QStyle::StandardPixmap 枚举类型