fb2text.h 731 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef FB2TEXT_H
  2. #define FB2TEXT_H
  3. #include <QResizeEvent>
  4. #include <QTextEdit>
  5. #include <QTimer>
  6. class Fb2TextEdit : public QTextEdit
  7. {
  8. Q_OBJECT
  9. public:
  10. Fb2TextEdit(QWidget* parent = 0)
  11. : QTextEdit(parent)
  12. {
  13. m_timer.setInterval( 100 );
  14. m_timer.setSingleShot(true);
  15. connect(&m_timer, SIGNAL(timeout()), SLOT(doResize()));
  16. }
  17. protected slots:
  18. void doResize() {
  19. QResizeEvent event(size(), m_size);
  20. QTextEdit::resizeEvent(&event);
  21. }
  22. protected:
  23. void resizeEvent( QResizeEvent* e ) {
  24. if (!m_timer.isActive()) m_size = e->oldSize();
  25. m_timer.start();
  26. }
  27. private:
  28. QTimer m_timer;
  29. QSize m_size;
  30. };
  31. #endif // FB2TEXT_H