c++ - QTabWidget corner QToolButton widget disappearing -


i have qtabwidget dynamically added , removed tabs. have qtoolbutton set corner widget in order handle add events on clicked() signal.

while adding works fine removing tabs widget causes button disappear. have tried using stylesheets create invisible first tab of width 0, approach failed me. because have settabsclosable(true) on tabs makes space close button.

i thought button disappearing when qtabbar collapses hight 0 when there no tabs. tried tabbar()->setminimumheight(30); workaround didn't work. ideas?

here code sample reproducing problem:

#include "mainwindow.h" #include "ui_mainwindow.h" #include "qtoolbutton"  mainwindow::mainwindow(qwidget *parent) :     qmainwindow(parent),     ui(new ui::mainwindow) {     ui->setupui(this);      ui->tabwidget->settabsclosable(true);     ui->tabwidget->tabbar()->setminimumheight(30);      qtoolbutton *btn = new qtoolbutton(ui->tabwidget);     btn->settext("add new");     btn->setcursor(qt::arrowcursor);     btn->setautoraise(true);     ui->tabwidget->setcornerwidget(btn, qt::topleftcorner);      qdebug() << ui->tabwidget->cornerwidget(qt::topleftcorner);        connect(ui->tabwidget, signal(tabcloserequested(int)), this, slot(closetab(int)));  }  mainwindow::~mainwindow() {     delete ui; }  //slot void mainwindow::closetab(int index) {     ui->tabwidget->removetab(index);     if(ui->tabwidget->count() == 0)         qdebug() << ui->tabwidget->cornerwidget(qt::topleftcorner); } 

i've got solved. need fix minimum height both qtoolbutton , qtabbar.

so far i've got code working in python:

def initialise()     # initialise tab widget need     self.tabcloserequested.connect(self.removetab)  def removetab(self,index):     h = self.cornerwidget().height()      self.removetab(index)     self.update()     if self.count() == 0:         self.cornerwidget().setminimumheight(h)         self.setminimumheight(h) 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -