注目のプログラム例
Qt+C++はライトストリップアニメーションの移動位置変換を実現し、マーキー画像カルーセルを移動します
動作環境のインストールやリモート デバッグが必要な場合は、記事の下部にある個人用QQ名刺を参照してください。専門および技術担当者がリモートでサポートします。
序文
このブログは、<<Qt+C++ によるライト ストリップ アニメーションのモーション位置変更、マーキー画像カルーセルの移動を実現>> のコードを書いています。コードはきちんとしていて、規則的で、読みやすいです。学習およびアプリケーションの推奨の最初の選択肢。
記事ディレクトリ
1. 必要なツールソフトウェア
2. ステップを使用する
1.ライブラリをインポートする
2. コードの実装
3. 走行結果
3. オンラインサポート
1. 必要なツールソフトウェア
1.VS、Qt
2.C++
2. ステップを使用する
1.ライブラリをインポートする
#include "MainWindow.h"
#include<iostream>
#include <QDebug>
#include <QFile>
#include <QTimer>
#include<QImage>
#include<QPixmap>
#include<QTransform>
#include<QPropertyAnimation>
#include<QGraphicsPixmapItem>
#include<QGraphicsScene>
#include <QtConcurrent/QtConcurrent>
#include <QPainter>
2. コードの実装
コードは以下のように表示されます。
class MarqueeWidget : public QWidget {
public:
MarqueeWidget(QWidget *parent = nullptr) : QWidget(parent) {
setFixedSize(400, 100);
label = new QLabel(this);
label->setGeometry(0, 0, width(), height());
timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &MarqueeWidget::updateMarquee);
marqueeText = "This is a marquee text.";
marqueeIndex = 0;
startMarquee();
}
void startMarquee() {
if (!timer->isActive()) {
timer->start(100); // 设置滚动速度,单位为毫秒
}
}
void stopMarquee() {
if (timer->isActive()) {
timer->stop();
}
}
void updateMarquee() {
const int textLength = marqueeText.length();
const int visibleLength = width() / fontMetrics().averageCharWidth();
if (textLength <= visibleLength) {
label->setText(marqueeText);
return;
}
QString displayText = marqueeText.mid(marqueeIndex) + marqueeText.left(marqueeIndex);
label->setText(displayText);
marqueeIndex++;
if (marqueeIndex >= textLength) {
marqueeIndex = 0;
}
}
private:
QLabel *label;
QTimer *timer;
QString marqueeText;
int marqueeIndex;
};
3. 走行結果
3. オンラインサポート:
動作環境のインストールやリモート デバッグが必要な場合は、 記事の下部にある個人用 QQ名刺を参照してください。専門および技術担当者がリモートでサポートします。 1) リモートインストールおよび操作環境、コードデバッグ2) Qt、C++、Python エントリーガイド3) インターフェース美化4) ソフトウェア制作
現在の記事リンク: Python+Qt デスクトップと Web ページのヒューマン カスタマー サービス コミュニケーション ツール_alicema1111 のブログ - CSDN ブログ
ブロガーおすすめ記事: Python 顔認識統計 QT フォーム - CSDN ブログ
ブロガーおすすめ記事: Python Yolov5 炎煙認識ソースコード共有 - CSDN ブログ
Python OpenCV は歩行者用入口に出入りする人の数を認識します - Python は人の数を認識します - CSDN ブログ
個人ブログ ホームページ: alicema1111 の blog_CSDN ブログ - Python、C++、Web ページ分野のブロガー
すべてのブロガーの記事はここをクリックしてください: alicema1111 の blog_CSDN ブログ - Python、C++、Web ページ分野のブロガー