美文网首页
Qt Examples Qt实例系列(一)

Qt Examples Qt实例系列(一)

作者: 田陌允 | 来源:发表于2019-05-30 16:01 被阅读0次

Movie Example

gif player

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下)


QStyle::StandardPixmap图标列表

关键代码如下:

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 枚举类型

相关文章

网友评论

      本文标题:Qt Examples Qt实例系列(一)

      本文链接:https://www.haomeiwen.com/subject/mpbwtctx.html