12, label controls

label can display text, hyperlinks, images, moving map

New Project Demo526, QMainWindow, check ui. The image folder (there are two pictures) are copied to the project path.

[Add image resource file]

Demo526 project at the right AddNew, Qt, Qt Resource File, name the image, OK. image.qrc file appears.

After adding the figure below, under Ctrl + S to save it will appear in the directory.

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMovie> //引入动画,GIF需要

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui -> setupUi ( the this );
     // text 
    ui-> labelText-> setText ( " Photo Gallery " );
     // JPG 
    ui-> labelJPG-> setPixmap (QPixmap ( " : /image/1.jpg " ));
    ui -> labelJPG-> setScaledContents ( to true ); // image size to adapt to label
     // GIF 
    QMovie * m = new new QMovie ( " : /image/1.gif " ); // create an animation 
    ui-> labelGIF-> setMovie ( m); // display the animation 
    M-> start (); // start 
    ui-> labelGIF-> setScaledContents ( to true );
     // HTML 
    ui-> labelURL-> the setText ( " <h1 of> <A the href = \" HTTPS : //www.cnblogs.com/xixixing \ "> evening westbound blog </a> </ h1> " );
    ui -> labelURL-> setOpenExternalLinks ( to true ); // open hyperlinks

}

MainWindow :: ~ MainWindow ()
{
    delete ui;
}

 

Guess you like

Origin www.cnblogs.com/xixixing/p/10927034.html