QLabel像视频一样显示图像
QLabel show images like a video
我尝试让QLabel像视频一样显示图像。
我希望它慢慢显示我的图像从 f0000.png 到 f0039.png这样我可以看到进度。
出于某种原因,我的 for 循环从 50 开始。
当我看到程序运行时,它只显示一个图像或变化太快,我看不到进度。
如何修复它让它显示视频等图像。
您可以使用Qtimer并根据需要设置更快的速度
页眉:
#include <QMainWindow>
#include <QTimer>
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
public slots:
void updateLabel();
private:
Ui::MainWindow *ui;
QTimer* _timer;
int index{0};
QString pixResource{};
};
和 IMPL。
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
_timer = new QTimer(parent);
connect(_timer, SIGNAL(timeout()), this, SLOT(updateLabel()));
_timer->start(1000);
}
MainWindow::~MainWindow()
{
delete ui;
_timer->stop();
delete _timer;
}
void MainWindow::updateLabel()
{
if (index >= 10)
{
index = 0;
}
qDebug() << "index: " << index;
pixResource = "res/foo/image/" + QString::number(index) + ".png";
qDebug() << "now the res: " << pixResource;
index++;
}
相关文章:
- 比较并显示使用最小值(a,b)和最大值(a、b)升序排列的4个数字
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 字符串-C++后显示的随机字符
- 继承期间显示未知行为的子类
- 仅使用绝对值对数组进行排序,并在C++中显示实际值
- 程序崩溃并显示"std::out_of_range"错误
- 如何在C++中用std::cout正确显示带十六进制的字符串文本
- 为什么在C的循环中使用printf的Rust代码不显示输出,而在C++的循环中显示std::cout
- 从数据库实时显示QT c++中的数据
- 当使用比格式支持的精度更高的精度来显示数字时,会写出什么数据
- 显示错误输出的简单数组排序程序
- Qt自定义QPush按钮未显示在布局上
- C++射线示踪剂ppm表示没有足够的数据来显示图像
- 显示基于用户输入的整数的字符
- 使用QTreeView,如何通过调用函数只突出显示特定的行/列
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- QLabel像视频一样显示图像
- 尝试显示 • œ,以及像 @ 一样的符号,仅在 C++ 中带有 g
- 将格式化文本显示到 QTextEdit 就像在 C 的 printf 中一样
- 如何在符号前面的映射值中显示与字符一样多的空格