62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
#ifndef CUSTOMTABWIDGET_H
|
|
#define CUSTOMTABWIDGET_H
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <QWidget>
|
|
#include <QStackedWidget>
|
|
#include "customtabbar.h"
|
|
|
|
//class CustomTabBar;
|
|
//class QStackedWidget;
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
class CustomTabWidget : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
CustomTabWidget(QWidget *parent = nullptr);
|
|
~CustomTabWidget();
|
|
void addTab(QWidget *widget, const QString &);
|
|
void addTab(QWidget *page, const QIcon &icon, const QString &label);
|
|
void addTabs(CustomTabWidget *);
|
|
int count() const;
|
|
int currentIndex() const;
|
|
QWidget *currentWidget() const;
|
|
int insertTab(int index, QWidget *page, const QString &label);
|
|
int insertTab(int index, QWidget *page, const QIcon &icon, const QString &label);
|
|
void removeTab(int index);
|
|
QString tabText(int index) const;
|
|
QWidget *tabWidget(int index) const;
|
|
void setAutoHideTabBar(bool bHide);
|
|
public slots:
|
|
void setCurrentIndex(int);
|
|
void slot_tabClose(int index);
|
|
|
|
signals:
|
|
void tabIsEmpty();
|
|
void currentTabChanged(const QString &);
|
|
protected:
|
|
void mousePressEvent(QMouseEvent *);
|
|
void mouseMoveEvent(QMouseEvent *);
|
|
void paintEvent(QPaintEvent *event);
|
|
void dragEnterEvent(QDragEnterEvent *event);
|
|
void dropEvent(QDropEvent *event);
|
|
|
|
private:
|
|
void setAutoDelete(bool bAuto); //标签页空时自动销毁
|
|
|
|
friend class CustomTabBar;
|
|
public:
|
|
CustomTabBar *m_pTabBar = nullptr;
|
|
QStackedWidget *m_pStackedWidget = nullptr;
|
|
QPoint m_dragStartPos;
|
|
bool m_bAutoDelete = false;
|
|
bool m_bAutoHideBar = false;
|
|
};
|
|
|
|
#endif // CUSTOMTABWIDGET_H
|