Qt Mobility Reference Documentation

hapticbutton.cpp Example File

hapticsquare/hapticbutton.cpp
 #include "hapticbutton.h"
 #include <QPainter>

 HapticButton::HapticButton(const QString &label) :
     QWidget(0), m_label(label), m_checked(false), m_checkable(false)
 {
     setMinimumSize(100, 100);
 }

 void HapticButton::mousePressEvent(QMouseEvent *)
 {
     if (m_checkable) {
         m_checked = !m_checked;
         emit toggled(m_checked);
     } else {
         emit clicked();
     }
 }

 void HapticButton::paintEvent(QPaintEvent *)
 {
     QPainter paint(this);

     QRect r(0, 0, width()-1, height()-1);
     paint.drawRoundedRect(r, 10, 10);
     paint.drawText(r, Qt::AlignCenter, m_label);
 }
X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.