1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00
LibQQt/src/widgets/qqtwidget.h

76 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef QQTWIDGET_H
#define QQTWIDGET_H
#include <QWidget>
#include <QTimer>
#include <QImage>
#include <qqt-local.h>
#include <qqtcore.h>
/*
* QSS美化和QQtWidget图片背景不能共存
* QSS部分影响QQtWidget比如Size等
*/
class QQTSHARED_EXPORT QQtWidget : public QWidget
{
Q_OBJECT
public:
enum ImageStyle
{
/**
* 整个居中,全面缩放显示
*/
QQTCENTER,
/**
* 切
* 从左上
* 会产生label的效果左右按照rect长但是不缩放形状
**/
QQTTILEDWIDTH,
QQTTILEDHEIGHT,
QQTTILED,
/**
* 缩放
* 忽略长宽比
*/
QQTZOOMWIDTH,
QQTZOOMHEIGHT,
QQTZOOM,
/**
* 缩放
* 保持长宽比
*/
QQTZOOMWIDTH_KEEPASPECTRATIO,
QQTZOOMHEIGHT_KEEPASPECTRATIO,
QQTZOOM_KEEPASPECTRATIO,
QQTIMAGESTYLEMAX
};
public:
explicit QQtWidget ( QWidget* parent = 0 );
virtual ~QQtWidget();
void setImageStyle ( ImageStyle style = QQTCENTER );
void setPixmap ( const QString& pic = QString() );
void setPixmap ( const QPixmap& pixmap );
void setPixmap ( const QImage& image );
// QWidget interface
protected:
void paintEvent ( QPaintEvent* ) override;
private:
quint32 m_style;
/*pixmap是必要的。绘图用pixmap。*/
/*内部没有使用QPixmap存储因为如果缩放widgetpixmap就没办法了img有*/
/*内部对QIcon的使用删除了icon不是必要的。*/
QImage mImage;
};
#endif // QWIDGET_H