Home > other >  QTabwidget QTabbar style set in question
QTabwidget QTabbar style set in question

Time:12-10

I made a QTabwidget, set up four labels, I want to let each TAB to fill me with separate background picture has now made it to the same background to fill the QTabbar class - this class, but I don't know how to set the picture alone to them? I give you to look at, the method to realize I do not know to have superior can solve my problem, thank you QTabWidget * tabview=new QTabWidget (win); Tabview - & gt; SetStyleSheet (" the QTabWidget: : pane {border - width: 0 px; } \ QTabWidget: : TAB - bar {border - width: 0 px; } \ QTabBar: : TAB {background - image: url (:/OK/skins/TAB button. The PNG); \ border - bottom - color: # C2C7CB; \ border - the top - left - the radius: 0 px; \ border - top - right - the radius: 0 px; \ min - width: 140 px; Min - height: 116 px; \ padding: 0 px; TAB: \} \ \ QTabBar...! Selected {\ margin - top: 0 px; \} \ QTabBar: : TAB: selected {\ background - image: url (/OK/skins/musicselect. PNG); \} \ QTabBar: : TAB: first: selected {\ margin - left: 0; \} \ QTabBar: : TAB: last: selected {\ margin - right: 0; \} \ QTabBar: : TAB: only - one {\ margin: 0; The \} ");

CodePudding user response:

By the way, no master BBS?

CodePudding user response:

I also want to know about this recently, single set label style

CodePudding user response:

Access to a single pointer, a use stylesheet Settings

CodePudding user response:

Can post access pointer code it show? I believe this will help a lot of people but in one case, even if get a pointer, the label is not QWidget subclasses, does not necessarily have setStyleSheet () the member function

CodePudding user response:

Is certainly QWidget class, not QWidget subclasses can't display, QTabBar should be the whole bar, rather than a label, see the QTabWidget source discovered that in fact it is only a QTabBar pointer, always thought that a label is a QTabBar, actually should be n label is also a QTabBar, QTabBar is a combination of all tags in the QTabWidget, function QTabBar * QTabWidget: : tabBar () can get QTabBar pointer, but this function is protected, so must to inherit a QTabWidget can obtain the pointer, obtain the QTabWidget pointer is used after the at (int index) should be able to obtain a single pointer

CodePudding user response:

I tried n the way I think you put the "label" and "tabs" disturb the two concepts I mean a single tag is not QWidget subclasses, and not to say that QTabBar not QWidget subclass carefully study the QTabBar will actually found a lot of strange things, such as: create a tabBar and addTab again, and then use the following code tabBar - & gt; SetTabsClosable (true); QObject * button=tabBar - & gt; The children (). At (0); TextEdit - & gt; Append (button - & gt; MetaObject () - & gt; The className ()); Will find that each label are the close button on the CloseButton class, but I found that don't have any CloseButton class in qt, later I found that it is the custom, for example: inherited from the QAbstractButton class to create a tabBar, then addTab once, and then use the following code tabBar - & gt; SetTabsClosable (true); TextEdit. Append (QString: : number (tabBar - & gt; The children (). The count ())); You'll find that at this point, a total of three tabBar child controls one of them is the CloseButton on the label, the other two are ToolButton, is the two buttons that make tags around mobile didn't find information about a single tag, let alone a single tag for the pointer now I don't even know, what is a single tag class inherits from what class also don't know

CodePudding user response:

Again, for example: just said the close button on each label is that CloseButton, then I hope to find each CloaeButton button on the label of the Parent information to find information on the label but only to find that the Parent is QTabBar CloseButton, rather than a single label my original idea is: the CloseButton Parent is the label and label is the Parent TAB bar but it happened that the CloseButton Parent is the TAB bar, middle don't have any thing about the label

CodePudding user response:

Actually to obtain the QTabWidget QTabBar pointer without inheritance so trouble as long as QTabBar * tabBar=tabWidget - & gt; FindChildren CodePudding user response:

Seems to be no this label parts, directly on an area that figure drawing TAB is actually QTabBar private data in a structure

CodePudding user response:

That is basically impossible to QTabBar TAB individually styled?

CodePudding user response:

I think Qt should not be so silly, QTabBar itself is QWidget, see setTabButton one method, should be able to set each TAB widget items, used, can try styled independently,
  • Related