使用setCornerWidget()没反应

想在tabWidget右上角添加一个按钮,按照网上说的
使用setCornerWidget()可以,但我使用却没反应

QToolButton* m_tabClosebutton = new QToolButton(this);
m_tabClosebutton->setIcon(QApplication::style()->standardIcon(QStyle::SP_DockWidgetCloseButton));
ui->tabWidgetTask->setCornerWidget(m_tabClosebutton);

这是我的代码
是不是那个tabWidget在格栅布局里,放进去没法显示

可以的,你的m_tabClosebutton 是在类的构造函数new的吗?如果不是就要调用show()