QTabBar : how see only a widget with the name of a tab ?



  • Hi,
    I have a QTabWidget and I'm searching for display only this (in blue) :
    0_1533118299097_1.PNG
    Does somebody have an idea?
    Thanks for advance.



  • @bozo6919

    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?



  • @koahnig

    Yes, just the square blue. not the greyish part with the triangle and the content of this tab, only the square blue



  • Nobody ?





  • It's not what I want
    I want to display only the square blue in the picture



  • @bozo6919

    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?



  • @bozo6919

    You like to place the ghost anywhere on the screen?



  • @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.



  • @bozo6919

    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.



  • @koahnig
    Ok, so it's impossible :/
    Yes I can create a QPushButton for replacing the text thanks



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.