首页| 论坛| 消息

标题:Qt动效StackWidget
作者:305750665
日期:2020-07-11 15:32
内容:

## Qt动效StackWidget
@
### 功能
1. QStackWidget有的AStackWidget都有
2. 支持设置动效时常
### 效果图

### 代码
```cpp
#include "AStackWidget.h"
#include
#include
AStackWidget::AStackWidget(QWidget *parent)
: QWidget(parent)
{
m_offset = 0;
m_curIndex = 0;
m_lastIndex = 0;
m_duration = 500;
m_moveAnimation = new QPropertyAnimation(this, "");
m_moveAnimation->setDuration(m_duration);
connect(m_moveAnimation, &QPropertyAnimation::valueChanged, this, &AStackWidget::onValueChanged);
}
AStackWidget::~AStackWidget()
{
}
int AStackWidget::count() const
{
return m_widgetLst.size();
}
int AStackWidget::currentIndex() const
{
return m_curIndex;
}
void AStackWidget::setDuration(int duration)
{
m_duration = duration;
}
int AStackWidget::addWidget(QWidget * widget)
{
int index = indexOf(widget);
if (index >= 0){
return index;
}
widget->setParent(this);
m_widgetLst.append(widget);
return count() - 1;
}
int AStackWidget::indexOf(QWidget * widget) const
{
return m_widgetLst.indexOf(widget);
}
int AStackWidget::insertWidget(int index, QWidget * widget)
{
int curindex = indexOf(widget);
if (curindex >= 0) {
return curindex;
}
widget->setParent(this);
m_widgetLst.insert(index, widget);
return index;
}
QWidge ..


#1 [305750665 07-11 15:35]
测试例子:
FrmAStackWidget::FrmAStackWidget(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
QList colorlst;
colorlst
#2 [boylebao 07-11 15:51]

#3 [alone_work 07-26 09:44]

#4 [oyp159753 12-01 16:46]

#5 [jobfind 10-18 16:24]

<< 1 2 >> (1/2)

回复 发表
主题 版块