zoukankan      html  css  js  c++  java
  • QT5-控件-QLabel和QLCDNumber-标签显示图片或者视频,LCD用于上位机不错

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QLabel>
    #include <QLCDNumber>
    #include <QPixmap>
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
        QLabel* label[10];
        QLCDNumber* lcd[10];
    };
    
    #endif // MAINWINDOW_H
    #include "mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
    {
        this->resize(600,400);
        this->centralWidget();
    
        label[0] = new QLabel("世界,不好",this);
        label[0]->setGeometry(10,30,200,40);
    
        QPixmap pix = QPixmap("res/01.png");
        label[1] = new QLabel(this);
        label[1]->setPixmap(pix);
        label[1]->setGeometry(10,70,300,300);
    
        lcd[0] = new QLCDNumber(2,this);
        lcd[0]->display("24");
        lcd[0]->setGeometry(350,30,200,100);
    
        lcd[0] = new QLCDNumber(5,this);
        lcd[0]->display("12:30");
        lcd[0]->setGeometry(350,150,200,100);
        // 设置显示样式
        // QLCDNumber::Outline 显示与窗口背景相同的颜色
        // QLCDNumber::Filled 显示与字体相同的颜色
        // QLCDNumber::Flat不显示字体外框线的风格
        //lcd[1]->setSegmentStyle(QLCDNumber::Filled);
    }
    
    MainWindow::~MainWindow()
    {
    
    }
    #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
    
        return a.exec();
    }

  • 相关阅读:
    meta标签
    Vue(day8)
    Vue(day7)
    Vue(day6)
    Flex布局
    Vue(day5)
    jquery.data()&jquery.extend()
    Promise对象
    Vue(day4)
    Vue(day3)
  • 原文地址:https://www.cnblogs.com/shiyumiao/p/5207982.html
Copyright © 2011-2022 走看看