简单实现在切换tab时,动画切换,
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPropertyAnimation>
#include <QPainter>
#include <QPen>
#include <QPalette>
#include <QBrush>
#include <QTabBar>
#include <QTabWidget>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_tabWidget_currentChanged(int index)
{
QWidget *widget0 = ui->tabWidget->widget(0);
QWidget *widget1 = ui->tabWidget->widget(1);
//QPixmap *pixmap = new QPixmap(widget->size());
QPixmap pixmap0 = QPixmap::grabWidget(widget0);//
QPixmap pixmap1 = QPixmap::grabWidget(widget1);//
QPixmap *pixmap = new QPixmap(pixmap0.width() + pixmap1.width() , pixmap0.height());
QImage image(pixmap0.width() + pixmap1.width() , pixmap0.height(