Radio单选框
默认互斥,加GroupBox进行分组可以解决这个
checkBox复选
ListWidget
TableWIdget:有表头
#include "widget.h"
#include "ui_widget.h"
#include <QMessageBox>
#include <QDebug>
#include <QMovie> Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this); connect(ui->radioButton, &QRadioButton::released, this, [=]()
{
QMessageBox::information(this, "radiobutton", "haha+++");
}); connect(ui->checkBox, &QCheckBox::stateChanged, this, [=](int state)
{
//QMessageBox::information(this, "checkbox", QString::number(state));
qDebug() << state;
}); ui->listWidget->addItem("hello, 软件园!");
QListWidgetItem* item = new QListWidgetItem(QIcon("D:\\Luffy.png"), "Luffy", ui->listWidget);
ui->listWidget->addItem(new QListWidgetItem(QIcon("D:\\Luffy.png"), "luffy")); // 1. 指定行数
ui->tableWidget->setRowCount();
// 2. 指定列数
ui->tableWidget->setColumnCount();
QStringList list;
list << "姓名" << "性别" << "年龄";
ui->tableWidget->setHorizontalHeaderLabels(list); ui->tableWidget->setItem(,,new QTableWidgetItem(QIcon(":/Image/face.png"),"haha"));
ui->tableWidget->setItem(,,new QTableWidgetItem(QIcon(":/Image/face.png"),"haha"));
ui->tableWidget->setItem(,,new QTableWidgetItem(QIcon(":/Image/face.png"),"haha")); ui->tableWidget->setItem(,,new QTableWidgetItem("Mar"));
ui->tableWidget->setItem(,,new QTableWidgetItem("Mar"));
ui->tableWidget->setItem(,,new QTableWidgetItem("Mar")); connect(ui->btnMusic, &QPushButton::clicked, this, [=]()
{
ui->stackedWidget->setCurrentIndex();
});
connect(ui->btnVideo, &QPushButton::clicked, this, [=]()
{
ui->stackedWidget->setCurrentWidget(ui->video);
});
connect(ui->btnOther, &QPushButton::clicked, this, [=]()
{
ui->stackedWidget->setCurrentIndex();
}); //ui->image->setPixmap(QPixmap(":/Image/Luffy.png"));
QMovie* movie = new QMovie(":/Image/mario.gif");
ui->image->setMovie(movie);
movie->start(); // 启动播放
} Widget::~Widget()
{
delete ui;
}
QLable
#include "mywidget.h"
#include "ui_mywidget.h"
#include <QListWidget>
#include <QListWidgetItem>
#include <QTableWidget>
#include <QTableWidgetItem>
#include <QMovie> MyWidget::MyWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::MyWidget)
{
ui->setupUi(this);
ui->listWidget->addItem("hello world");
QListWidgetItem *item = new QListWidgetItem(QIcon(":/Image/Luffy.png"),"Luffy",ui->listWidget);
ui->listWidget->addItem(item); ui->tableWidget->setRowCount();
ui->tableWidget->setColumnCount();
QStringList h_list;
h_list << "姓名" << "性别" << "年龄" ;
ui->tableWidget->setHorizontalHeaderLabels(h_list); //QTableWidgetItem *t_item = new QTableWidgetItem(QIcon(":/Image/face.png"),"haha");
ui->tableWidget->setItem(,,new QTableWidgetItem(QIcon(":/Image/face.png"),"haha"));
ui->tableWidget->setItem(,,new QTableWidgetItem(QIcon(":/Image/face.png"),"haha"));
ui->tableWidget->setItem(,,new QTableWidgetItem(QIcon(":/Image/face.png"),"haha")); ui->tableWidget->setItem(,,new QTableWidgetItem("Mar"));
ui->tableWidget->setItem(,,new QTableWidgetItem("Mar"));
ui->tableWidget->setItem(,,new QTableWidgetItem("Mar")); QStringList l_text;
l_text << "北京" << "上海" << "深圳";
ui->comboBox->addItems(l_text); connect(ui->btmMusic,&QPushButton::clicked,this,[=](){
ui->stackedWidget->setCurrentIndex();
}); connect(ui->btnMovie,&QPushButton::clicked,this,[=](){
ui->stackedWidget->setCurrentIndex();
}); connect(ui->btnOther,&QPushButton::clicked,this,[=](){
ui->stackedWidget->setCurrentIndex();
}); //QLabel *qlb = new QLabel(this);
ui->Iconlabel->setPixmap(QPixmap(":/Image/butterfly1.png")); QMovie *movie = new QMovie(":/Image/mario.gif");
ui->movie_label->setMovie(movie);
movie->start(); // 启动播放
} MyWidget::~MyWidget()
{
delete ui;
}