close

image


image

Change tabPosition


image

Change tabShape

image

Change currentTabText


image


Set tabClosable property checked

image


image


void MainWindow::on_tabWidget_tabCloseRequested(int index)
{
    ui->tabWidget->removeTab(index);
}


Add a tab with a specific name

image


Add multiple tabs with name by its order

image


image

image

image


image


form.h

#ifndef FORM_H
#define FORM_H
 
#include <QWidget>
 
namespace Ui {
class Form;
}
 
class Form : public QWidget
{
    Q_OBJECT
 
public:
    explicit Form(QWidget *parent = nullptr);
    ~Form();
 
private slots:
    void on_pushButton_clicked();
 
public slots:
    void run_job_periodically();
 
private:
    Ui::Form *ui;
    int counter;
    QTimer *timer;
};
 
#endif // FORM_H

form.cpp

#include "form.h"
#include "ui_form.h"
#include <QtCore>
 
Form::Form(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Form)
{
    ui->setupUi(this);
    timer = new QTimer(this);
    counter = 0;
    connect(timer, SIGNAL(timeout()), this, SLOT(run_job_periodically()));
}
 
Form::~Form()
{
    delete ui;
}
 
void Form::on_pushButton_clicked()
{
    timer->start(500);
}
 
void Form::run_job_periodically()
{
    counter++;
    ui->label->setText(QString::number(counter));
}

form.ui

image


image


Dynamically add sever tabWidgets with timer


image




References:


1. Qt Tutorials For Beginners 28 - QTabWidget


2. [QT教學] QT超簡單教學Day-2 ( Timer , Thread )-上

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 me1237guy 的頭像
    me1237guy

    天天向上

    me1237guy 發表在 痞客邦 留言(0) 人氣()