I have a QTabWidget
with its tabs on the West, then I tried to add a corner widget to it, but it did not appear. If I set the tabs position to North or South, the corner widget gets displayed, but not on the side.
Here's an MRE:
QWidget *w = new QWidget();
QTabWidget *t = new QTabWidget(w);
w->setMinimumSize(800,600);
t->addTab(new QWidget(),"Tab");
t->addTab(new QWidget(),"Tab");
t->addTab(new QWidget(),"Tab");
t->addTab(new QWidget(),"Tab");
t->setTabPosition(QTabWidget::TabPosition::East);
t->setGeometry(100,100,400,400);
QPushButton *button = new QPushButton("Button");
//for debugging purposes
button->setObjectName("ss");
//for debugging purposes
t->setStyleSheet("background: red");
button->setStyleSheet("background: blue;");
//for debugging purposes
t->setCornerWidget(button1,Qt::TopLeftCorner);
//t->setCornerWidget(button1,Qt::TopRightCorner);
//t->setCornerWidget(button1,Qt::BottomLeftCorner);
//t->setCornerWidget(button1,Qt::BottomRightCorner);
w->show();
//for debugging purposes
//qDebug()<<button->geometry();
//button->setGeometry(0,0,50,50);
//for debugging purposes
button->connect(button,&QPushButton::clicked,[](){qDebug()<<"corner widget click?";});
I tried to use all 4 corners, and right corners have no effect, but the left causes an empty space before the tabs, here's how it looks, the empty space is at the top right corner:
I tried to set the stylesheet of the button I'm using as a corner widget, so that it might appear if hidden, but resulted in nothing.
I checked the button's geometry, and it got QRect(0,0 0x0)
, and that is after using show()
. So i tried to set its geometry, but resulted in nothing as well (but the geometry got updated correctly), button still not displayed.
I also tried to check for the button whereabouts by connecting its clicked()
signal to a qDebug()
, I clicked all over the widget and got no output.
Note: Corner widgets are designed for North and South tab positions; other orientations are known to not work properly.
I get from that, that it's not entirely impossible to get it to work.
How to get a QTabWidget
corner widget on the side?