Solved How to hide a page of tabview?
-
Could you check if
ui->tabWidget->tabBar()->tabButton(0,QTabBar::LeftSide)
returns null? -
Dear @VRonin,
How???Regards,
Mucip:) -
@Mucip said in How to hide a page of tabview?:
How???
if(ui->tabWidget->tabBar()->tabButton(0,QTabBar::LeftSide)==nullptr) qDebug("It's NULL!");
-
Dear @VRonin ,
Yes. It returns NULL... ?!Regards,
Mucip:) -
to quote Chris-Kawa from this thread 5 years ago:
@Chris-Kawa said in [Solved] Hiding tab from QTabWidget made in QtCreator:
There's no built in method like setTabVisible(false) unfortunately.
The workaround I often use is applying this stylesheet:
@
QTabWidget::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }
@
and then using setTabEnabled(false).
Of course if you also need disabled (grayed out) tabs this method won't work. -
Dear @J.Hilk ,
I have seen this before but ıt must be easier way I guess...
I tryed styleshit but I do not know much about stylsheet?!...
Regards,
Mucip:) -
@Mucip
well it should be pretty simple and kind of self-explanatorytabWidget->setStyleSheet("QTabWidget::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }"); //This needs to be done once, preverably in your constructor or inside QtDesigner, should you use it //On hide Tab_0 clicked tabWidget->setTabEnabled(0, false);
-
Dear @J.Hilk ,
Yes. It worked... :)
But the tab label is still visible?!...Regards,
Mucip:) -
@Mucip
I'm not sure what you mean exactlybut you can take a look here:
http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbarwhat else you can do with the QTabWidget and QStyleSheet
-
Dear @J.Hilk ,
You may check:
Before Hide status:
After Hide Status:
Yes. It's disabeld but tab labels are still visible?!... :(
Regards,
Mucip:) -
@Mucip
sry, 5 years i s a long time, stuff changes.The stylesheet is supposed to be
QTabBar
notQTabWidget
tabWidget->setStyleSheet("QTabBar::tab:disabled { width: 0; height: 0; margin: 0; padding: 0; border: none; }");
-
Dear @J.Hilk ,
Yes thanks. But something happening strange! I do not know why? Very little part of the picture (picture labels of first tab which is just hided!) remain back. Whan I click other tabs than it disappears... ?!
Strange?!...
Regards,
Mucip:)