QTabBar : how see only a widget with the name of a tab ?
-
If your QTabBar has ultimately only one tab to create the ghost, which you are freely moving somewhere as I understand your application now, then the QTabBar is not the right approach.
Why not using a QPushButton to create the ghost?
The push button could be changed in style to your likings. It will have not the greyish appendix, you are trying to get rid off.
-
Hi,
I have a QTabWidget and I'm searching for display only this (in blue) :
Does somebody have an idea?
Thanks for advance. -
Do you mean only the tab (as it says Empty) and possibly other tabs, when added.
But the greyish part with the triangle on the right should disappear? -
I think you should take a look at Stylesheets:
http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar -
I am wondering if there is a misunderstanding.
The QTabBar suggest that you are looking ultimately for a row of distinguished blue rectancles with labels "Empty", "Tab1", "Tab2" and so on.
If you want to limit to one tab as in your example, you might on a entirely wrong route.
Perhaps something like QLabel would fit better?
-
I am wondering if there is a misunderstanding.
The QTabBar suggest that you are looking ultimately for a row of distinguished blue rectancles with labels "Empty", "Tab1", "Tab2" and so on.
If you want to limit to one tab as in your example, you might on a entirely wrong route.
Perhaps something like QLabel would fit better?
@koahnig
no, I'm going to explain what I want :
First, I have a QMainWindow and inside it, QTabWidget with a QTabbedBar.
I have an event with QTabbedBar :
When the user clicked on the tab (the square blue), I want to create a ghost of this tab (only the square blue).
This ghost has (after) to follow the mouse of the user. (This part of the code worked already)
Do you understand? -
@koahnig
no, I'm going to explain what I want :
First, I have a QMainWindow and inside it, QTabWidget with a QTabbedBar.
I have an event with QTabbedBar :
When the user clicked on the tab (the square blue), I want to create a ghost of this tab (only the square blue).
This ghost has (after) to follow the mouse of the user. (This part of the code worked already)
Do you understand? -
@koahnig
The ghost has to follow the cursor, and when I release the mouse, my widget moves at the same place as the ghost and the ghost is destroyed.If your QTabBar has ultimately only one tab to create the ghost, which you are freely moving somewhere as I understand your application now, then the QTabBar is not the right approach.
Why not using a QPushButton to create the ghost?
The push button could be changed in style to your likings. It will have not the greyish appendix, you are trying to get rid off.
-
If your QTabBar has ultimately only one tab to create the ghost, which you are freely moving somewhere as I understand your application now, then the QTabBar is not the right approach.
Why not using a QPushButton to create the ghost?
The push button could be changed in style to your likings. It will have not the greyish appendix, you are trying to get rid off.
-
So, I managed to do this like that:
Tabbed::Tabbed(TabbedBar *tabbedBar) : QWidget(nullptr, Qt::FramelessWindowHint) { QPalette palette; TabbedView *tabbedBarGhost = createTabGhost(tabbedBar); palette.setBrush(this->backgroundRole(), QBrush(tabbedBarGhost->tab->grab())); this->setPalette(palette); this->setGeometry(tabbedBarGhost->tab->geometry()); this->setWindowOpacity(0.5); delete tabbedBarGhost; } TabbedView *TabbedGhost::createTabGhost(TabbedBar *tabbedBar) { TabbedView *tabbedBarGhost = new TabbedView(nullptr); int index = tabbedBar->currentIndex(); QString text = tabbedBar->tabbedView->tabText(index); QWidget *widget = new QWidget; tabbedBarGhost->addTab(widget, text); tabbedBarGhost->setWindowOpacity(0); tabbedBarGhost->show(); return tabbedBarGhost; }
A TabbedBar is inherit of a QTabBar
A TabbedView is inherit of a QTabWidget