Solved How to hide a page of tabview?
-
Hi,
Is there any way to hide one page of tabview?. There is removeTab function but I do not want to fallow this way. Because I have some signal/slots on the pages and when I remove the tab then compiler makes error!...
regards,
Mucip:) -
You could try
tabWidget->tabBar()->tabButton(i)->hide()
where i is the index of the tab -
Hi,
I could'nt find this on TabWidget?! Am I wrong?...
Regards,
Mucip:) -
-
Hi @VRonin ,
When I use below code raise error and crashed!ui->tabWidget->tabBar()->tabButton(0,QTabBar::LeftSide)->hide();
When I remove "QTabBar::LeftSide" then compiler error comes up! And asking for the second input to the function. :(
Regards,
Mucip:) -
@Mucip said in How to hide a page of tabview?:
raise error and crashed
Could you post the stack trace?
-
Hi,
I hope I understood correct,
1 QWidget::hide qwidget.cpp 8058 0x317270f
2 MainWindow::on_pushButton_2_clicked mainwindow.cpp 50 0x401a20
3 MainWindow::qt_static_metacall moc_mainwindow.cpp 76 0x401ac6
4 MainWindow::qt_metacall moc_mainwindow.cpp 109 0x401bb8
5 QMetaObject::metacall qmetaobject.cpp 301 0x6bb14231
6 QMetaObject::activate qobject.cpp 3781 0x6bb3272b
7 QMetaObject::activate qobject.cpp 3628 0x6bb32921
8 QAbstractButton::clicked moc_qabstractbutton.cpp 308 0x3248afc
9 QAbstractButtonPrivate::emitClicked qabstractbutton.cpp 414 0x3248d25
10 QAbstractButtonPrivate::click qabstractbutton.cpp 407 0x324a4ca
11 QAbstractButton::mouseReleaseEvent qabstractbutton.cpp 1011 0x324a6fa
12 QWidget::event qwidget.cpp 8817 0x318b046
13 QAbstractButton::event qabstractbutton.cpp 968 0x324bb0c
14 QPushButton::event qpushbutton.cpp 682 0x32dfc21
15 QApplicationPrivate::notify_helper qapplication.cpp 3732 0x31486dc
16 QApplication::notify qapplication.cpp 3208 0x3150252
17 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1044 0x6bb0af83
18 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 237 0x314f2f1
19 QApplicationPrivate::sendMouseEvent qapplication.cpp 2709 0x314f2f1
20 QWidgetWindow::handleMouseEvent qwidgetwindow.cpp 655 0x31a1aa3
21 QWidgetWindow::event qwidgetwindow.cpp 273 0x31a3b99
22 QApplicationPrivate::notify_helper qapplication.cpp 3732 0x31486dc
23 QApplication::notify qapplication.cpp 3104 0x314fcd4
24 QCoreApplication::notifyInternal2 qcoreapplication.cpp 1044 0x6bb0af83
25 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 237 0xd06a9f7
26 QGuiApplicationPrivate::processMouseEvent qguiapplication.cpp 1957 0xd06a9f7
27 QGuiApplicationPrivate::processWindowSystemEvent qguiapplication.cpp 1741 0xd06c229
28 QWindowSystemInterface::sendWindowSystemEvents qwindowsysteminterface.cpp 976 0xd04ce5d
29 QWindowsGuiEventDispatcher::sendPostedEvents qwindowsguieventdispatcher.cpp 82 0x62ababb4
30 qt_internal_proc(HWND__ *, unsigned int, unsigned int, long) *16 qeventdispatcher_win.cpp 237 0x6bb5b9fd
31 USER32!AddClipboardFormatListener 0x7703e0bb
32 USER32!EndTask 0x77048849
33 QEventDispatcherWin32Private::sendTimerEvent qeventdispatcher_win.cpp 456 0x6bb5b439
34 ?? 0x550e72
35 USER32!EndTask 0x7704b145
36 ?? 0x401
37 ?? -
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:)