Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qcollapsible font size / style #231

Open
carsen-stringer opened this issue Feb 13, 2024 · 3 comments
Open

qcollapsible font size / style #231

carsen-stringer opened this issue Feb 13, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@carsen-stringer
Copy link

Love the QCollapsible class! (and the rangeslider!) I tried using "setFont" with QCollapsible and couldn't change the font style for the title (like you can for a QGroupBox). Is it possible in a different way? Thanks.

@carsen-stringer carsen-stringer added the enhancement New feature or request label Feb 13, 2024
@tlambert03
Copy link
Member

Hey @carsen-stringer,

looks like that hasn't been exposed fully. I'll give you a workaround that uses a private attribute, and we'll have to fix it with a PR. The main text that you see in a QCollapsible (the text that you can click to expand/collapse) is actually a QPushButton that is accessible at QCollapsible._toggle_btn.

So, as a workaround, you could use:

wdg = QCollapsible('toggle me')
font = wdg.font()
# modify the font
wdg._toggle_btn.setFont(font)

@tlambert03
Copy link
Member

tlambert03 commented Feb 14, 2024

it's also perhaps worth nothing that that only adjust the top level text, but not widgets you've added inside. So, another option that doesn't require private attribute access, and which controls all of them:

# where wdg is a QCollapsible
for child in wdg.children():
    if isinstance(child, QWidget):
        child.setFont(font)

@carsen-stringer
Copy link
Author

carsen-stringer commented Feb 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants