I want to have text editor widget that resize text on mouse wheel scroll (like in Qt Creator for example). So I made my class:
Qt Code:
  1. class MyTextEdit : public QTextEdit
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. MyTextEdit(QWidget* parent = 0) :
  7. QTextEdit(parent),
  8. fontSize(8)
  9. {
  10. connect(this, SIGNAL(fontSizeChanged(qreal)), this, SLOT(setFontPointSize(qreal)));
  11. }
  12.  
  13. signals:
  14. void fontSizeChanged(qreal);
  15.  
  16. protected:
  17. void wheelEvent(QWheelEvent* e)
  18. {
  19. if ((e->modifiers() == Qt::ControlModifier) && (e->delta() > 0))
  20. {
  21. fontSize += 0.5;
  22. emit fontSizeChanged(fontSize);
  23. std::cout << fontSize << " " << fontPointSize () << std::endl;
  24. }
  25. else if ((e->modifiers() == Qt::ControlModifier) && (e->delta() < 0) && (fontSize > 0.5))
  26. {
  27. fontSize -= 0.5;
  28. emit fontSizeChanged(fontSize);
  29. std::cout << fontSize << " " << fontPointSize () << std::endl;
  30. }
  31. else
  32. QTextEdit::wheelEvent(e);
  33. }
  34.  
  35. private:
  36. qreal fontSize;
  37. };
To copy to clipboard, switch view to plain text mode 

But it don't work. Can anyone help? :-)

---
Sorry for bad english, hope it is understandable