I would like to hide the text and just show the icons on the tabs of my QTabWidget when the user resizes the QTabWidget and hits the minimumSizeHint with the text showing.
Everything is working fine except when I hide the text I have to release the mouse and click again to continue shrinking the widget, even though I hide the text and call updateGeometry().

I tried to do this with an event filter. Is there a better way to do this and is this even possible?
I am using Qt 4.5.2.

Qt Code:
  1. class TabWidgetEventFilter : public QObject
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. TabWidgetEventFilter(QObject* parent, QTabWidget* tabWidget)
  7. : QObject(parent)
  8. {
  9. if (!tabWidget)
  10. return;
  11.  
  12. _tabWidget = tabWidget;
  13.  
  14. for (int i = 0; i < _tabWidget->count(); ++i)
  15. _tabNames.append(_tabWidget->tabText(i));
  16.  
  17. _minimumSizeHintWithText = _tabWidget->minimumSizeHint().width();
  18. }
  19.  
  20. protected:
  21. bool eventFilter(QObject* obj, QEvent* event)
  22. {
  23. if (event->type() == QEvent::Resize)
  24. {
  25. QResizeEvent* resizeEvent = static_cast<QResizeEvent*>(event);
  26. if (resizeEvent->size().width() <= _minimumSizeHintWithText)
  27. setTextVisible(false);
  28. else
  29. setTextVisible(true);
  30. }
  31.  
  32. return false;
  33. }
  34.  
  35. private:
  36. void setTextVisible(bool visible)
  37. {
  38. for (int i = 0; i < _tabWidget->count(); ++i)
  39. _tabWidget->setTabText(i, visible ? _tabNames.at(i) : QString(""));
  40.  
  41. _tabWidget->updateGeometry();
  42. }
  43.  
  44. QList<QString> _tabNames;
  45. QTabWidget* _tabWidget;
  46. int _minimumSizeHintWithText;
  47. };
To copy to clipboard, switch view to plain text mode 

Thanks for any help
Michael