close
Change tabPosition
Change tabShape
Change currentTabText
Set tabClosable property checked
void MainWindow::on_tabWidget_tabCloseRequested(int index)
{
ui->tabWidget->removeTab(index);
}
Add a tab with a specific name
Add multiple tabs with name by its order
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
Dynamically add sever tabWidgets with timer
References:
1. Qt Tutorials For Beginners 28 - QTabWidget
全站熱搜
留言列表