Note that there are some explanatory texts on larger screens.

plurals
  1. POQTabWidget corner QToolButton widget disappearing
    primarykey
    data
    text
    <p>I have a QTabWidget with dynamically added and removed tabs. I have also a QToolButton set as a corner widget in order to handle add events on its <code>clicked()</code> signal.</p> <p>While adding works perfectly fine removing all tabs from the widget causes the button to disappear. I have tried using stylesheets to create a invisible first tab of width 0, but this approach failed me. Probably because I have <code>setTabsClosable(true)</code> on all tabs which makes space for the close button.</p> <p>I also thought that button is disappearing when QTabBar collapses its hight to 0 when there is no tabs. I tried to <code>tabBar()-&gt;setMinimumHeight(30);</code> but this workaround also didn't work. Any ideas?</p> <p>Here my code sample reproducing the problem:</p> <pre><code>#include "mainwindow.h" #include "ui_mainwindow.h" #include "QToolButton" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui-&gt;setupUi(this); ui-&gt;tabWidget-&gt;setTabsClosable(true); ui-&gt;tabWidget-&gt;tabBar()-&gt;setMinimumHeight(30); QToolButton *btn = new QToolButton(ui-&gt;tabWidget); btn-&gt;setText("Add new"); btn-&gt;setCursor(Qt::ArrowCursor); btn-&gt;setAutoRaise(true); ui-&gt;tabWidget-&gt;setCornerWidget(btn, Qt::TopLeftCorner); qDebug() &lt;&lt; ui-&gt;tabWidget-&gt;cornerWidget(Qt::TopLeftCorner); connect(ui-&gt;tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); } MainWindow::~MainWindow() { delete ui; } //SLOT void MainWindow::closeTab(int index) { ui-&gt;tabWidget-&gt;removeTab(index); if(ui-&gt;tabWidget-&gt;count() == 0) qDebug() &lt;&lt; ui-&gt;tabWidget-&gt;cornerWidget(Qt::TopLeftCorner); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload