Draw in an empty QTabWidget
Solved
General and Desktop
-
wrote on 17 Apr 2018, 09:38 last edited by
HI, I was wondering how to draw in an empty
QTabWidget
.
I noticed that when aQTabWidget
has no tabs it's just a white widget with nothing in it, I was wondering how to draw some texts over it and when the user creates a tab it disappears? -
Hi
Then you must subclass it and override paintEvent
and handle the no tab logic.Update:
very fast sample.class MyTab : public QTabWidget { Q_OBJECT public: explicit MyTab(QWidget* parent = nullptr) : QTabWidget(parent) {} protected: virtual void paintEvent(QPaintEvent* e ) override { QTabWidget::paintEvent(e); QPainter painter(this); if ( ! count() ) // has no tabs { painter.drawText( rect(), Qt::AlignCenter, "EMPTY"); } } };
1/2