Internal QWidgets of QTabBar's tab?

前端 未结 1 1416
抹茶落季
抹茶落季 2021-01-17 03:03

As a follow up of \" Hide label text for Qt tabs without setting text to empty string \" :

Can I directly access the widgets within the tabs of the QTabBar

1条回答
  •  迷失自我
    2021-01-17 03:46

    QTabBar header sections are not actually widgets. They are drawn by QStylePainter inside QTabBar::paintEvent. Thus you can't get access to them. As a workaround you can add a tab with an empty text and set a custom widget to it:

    QTabBar *bar = new QTabBar;
    bar->addTab("");
    
    QLabel *label = new QLabel("my label");
    bar->setTabButton(0, QTabBar::LeftSide, label);
    

    0 讨论(0)
提交回复
热议问题