Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    Tools
    3
    13
    1208
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bozo6919 last edited by

      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.

      Sorry for my English ^^'

      K 1 Reply Last reply Reply Quote 0
      • B
        bozo6919 @koahnig last edited by

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

        Sorry for my English ^^'

        1 Reply Last reply Reply Quote 0
        • K
          koahnig @bozo6919 last edited by

          @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?

          Vote the answer(s) that helped you to solve your issue(s)

          B 1 Reply Last reply Reply Quote 0
          • B
            bozo6919 @koahnig last edited by bozo6919

            @koahnig

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

            Sorry for my English ^^'

            1 Reply Last reply Reply Quote 0
            • B
              bozo6919 last edited by

              Nobody ?

              Sorry for my English ^^'

              1 Reply Last reply Reply Quote 0
              • D
                deleted372 last edited by

                I think you should take a look at Stylesheets:
                http://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar

                1 Reply Last reply Reply Quote 0
                • B
                  bozo6919 last edited by

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

                  Sorry for my English ^^'

                  K 1 Reply Last reply Reply Quote 0
                  • K
                    koahnig @bozo6919 last edited by

                    @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?

                    Vote the answer(s) that helped you to solve your issue(s)

                    B 1 Reply Last reply Reply Quote 1
                    • B
                      bozo6919 @koahnig last edited by

                      @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?

                      Sorry for my English ^^'

                      K 1 Reply Last reply Reply Quote 0
                      • K
                        koahnig @bozo6919 last edited by

                        @bozo6919

                        You like to place the ghost anywhere on the screen?

                        Vote the answer(s) that helped you to solve your issue(s)

                        B 1 Reply Last reply Reply Quote 0
                        • B
                          bozo6919 @koahnig last edited by

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

                          Sorry for my English ^^'

                          K 1 Reply Last reply Reply Quote 0
                          • K
                            koahnig @bozo6919 last edited by

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

                            Vote the answer(s) that helped you to solve your issue(s)

                            B 1 Reply Last reply Reply Quote 1
                            • B
                              bozo6919 @koahnig last edited by

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

                              Sorry for my English ^^'

                              1 Reply Last reply Reply Quote 0
                              • B
                                bozo6919 last edited by

                                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

                                Sorry for my English ^^'

                                1 Reply Last reply Reply Quote 1
                                • First post
                                  Last post