介绍
基于 QDialog 绘制的信息框,提供一个简单的信息显示,并带有一些动画,默认自动渐隐消失。背景色,字体色可设置,支持渐变色。
使用
#include "VMessageBox.h"
基本方法
// 根据parent 坐标 弹出信息框
//static void information(QWidget *parent, const QString &msg, int timeout = 2000, QString bgColor = 0, QString fontColor = 0);
// 根据提供的坐标 弹出信息框
static void information(const QPoint &point, const QString &msg, int timeout = 2000, QString bgColor = 0, QString fontColor = 0);
// 根据内置提供的坐标 弹出信息框
static void information(QWidget *parent, const QString &msg, const DefaultPoint &pointType = Center_Bottom, int timeout = 2000, const QString &bgColor = 0, const QString &fontColor = 0);
enum DefaultColor{ Gradient_Blue,Gradient_Red, Gradient_Green}; //内设颜色 不定时的会增加一些
enum DefaultPoint{ Center_Up, Center_Bottom }; //内置坐标
static QString getDefaultColor(DefaultColor colorIndex); //获得内设颜色
//自动判断颜色 parent
static void show(QWidget *parent, const QString &msg,
const QVariant &bgColor = QVariant(), int timeout = 2000, const DefaultPoint &pointType = Center_Bottom, const QString &fontColor = 0);
//自动判断颜色 坐标
static void show(QPoint point, const QString &msg,
const QVariant &bgColor = QVariant(), int timeout = 2000, const QString &fontColor = 0);
实例:
VMessageBox::information(this, "我是一个信息框"); //简单调用 位置居中
VMessageBox::information(QPoint(500,500), "我是一个信息框"); //简单调用 指定坐标弹出
VMessageBox::information(this, "我是一个信息框", 3000); //指定信息框存在时间
VMessageBox::information(this, "我是一个信息框", 3000, "red"); //设置背景色
VMessageBox::information(this, "我是一个信息框", 3000, "red", "pink"); //设置背景色和字体色
VMessageBox::information(this, "我是一个信息框", 3000, "#fff", "#000"); //设置背景色和字体色
VMessageBox::information(this, "我是一个信息框", 3000,
VMessageBox::getDefaultColor(VMessageBox::Gradient_Blue), "pink"); //使用内置渐变色
VMessageBox::show(this, "使用渐变色", ".........");
VMessageBox::show(this, "使用色值", "#FFF");
VMessageBox::show(this, "使用内置渐变色", VMessageBox::Gradient_Green);
实际项目展示:
内置颜色展示
Gradient_Blue 渐变蓝
Gradient_Red 渐变红
Gradient_Red 渐变绿
**