效果如下:

代码如下:
#include <QComboBox>
#include<QPropertyAnimation>
class CustomComboBox : public QComboBox
{
Q_OBJECT
public:
CustomComboBox(QWidget* parent = nullptr, int gap = 5);
~CustomComboBox()=default;
protected:
void showPopup() override;//重写showPopup()方法
void hidePopup() override;
private:
int m_gap = 5;//下拉列表和ComboBox的间距
QPropertyAnimation animation;
};
#include "CustomComboBox.h"
#include<QListView>
#include<QFile>
#include<QApplication>
#include<QDebug>
CustomComboBox::CustomComboBox(QWidget *parent, int gap):QComboBox(parent),m_gap(gap)
{
setAttribute(Qt::WA_StyledBackground);
this->setView(new QListView(this));
this->view()->window()->setWindowFlags(Qt::Popup
| Qt::FramelessWindowHint
| Qt

最低0.47元/天 解锁文章
1415

被折叠的 条评论
为什么被折叠?



