#include "ctextedit.h"

#include <QApplication>
#include <QDebug>

CTextEdit::CTextEdit(QWidget *parent)
    : QTextEdit(parent)
{
    mFontSize = 16;
}

void CTextEdit::wheelEvent(QWheelEvent *e)
{
    if(QApplication::keyboardModifiers() == Qt::ControlModifier)//ctrl键的判断
    {
        if(e->delta() > 0)
        {
            //放大
            QFont f = this->font();
            f.setPixelSize(f.pixelSize() + 1);
            this->setFont(f);
        }
        else
        {
            //缩小
            QFont f = this->font();
            f.setPixelSize(f.pixelSize() - 1);
            this->setFont(f);
        }
    }
    else
    {
        QTextEdit::wheelEvent(e);
    }
}
