#include "mainwindow.h" #include #include #include #include MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) { m_ptLast = QPoint(0, 0); m_font.setFamily("Comic Sans MS"); m_font.setPointSize(12); m_font.setBold(true); t_rcBound = QRectF(0, 0, 200, 400); m_strContent = "CRect( ) throw( ); \n" "CRect( \n" " int l, \n" " int t, \n" " int r, \n" " int b \n" ") throw( ); \n" "CRect( \n" " const RECT& srcRect \n" ") throw( ); \n" "CRect( \n" " LPCRECT lpSrcRect \n" ") throw( ); \n" "CRect( \n" " POINT point, \n" " SIZE size \n" ") throw( ); \n" "CRect( \n" " POINT topLeft, \n" " POINT bottomRight \n" ") throw( );"; } MainWindow::~MainWindow() {} void MainWindow::paintEvent(QPaintEvent*) { QPainter t_painter(this); t_painter.fillRect(t_rcBound, Qt::white); t_painter.setFont(m_font); QTime t_time(QTime::currentTime()); t_painter.drawText(t_rcBound, Qt::AlignTop | Qt::AlignLeft, m_strContent); //qDebug()<<"msecsTo: "<setWindowTitle(QString("%1").arg(t_time.msecsTo(QTime::currentTime()))); } void MainWindow::mousePressEvent(QMouseEvent* event) { m_ptLast = event->pos(); } void MainWindow::mouseMoveEvent(QMouseEvent* event) { update(t_rcBound.toRect()); t_rcBound.translate(event->pos() - m_ptLast); update(t_rcBound.toRect()); m_ptLast = event->pos(); } void MainWindow::mouseReleaseEvent(QMouseEvent* event) { update(t_rcBound.toRect()); t_rcBound.translate(event->pos() - m_ptLast); update(t_rcBound.toRect()); m_ptLast = event->pos(); }