Ancestors

Toot

Written by Chris Huck :freecad: :ubuntu: on 2024-12-29 at 17:32

This is a question for the #FreeCAD #macro people: I’ve created a dialog box with 3 radio buttons. The correct default button is selected, but I can’t figure out why the first button is highlighted? I’ve been reading through the documentation for QRadiobutton, but I can’t figure out why the toggled button isn’t highlighted.

Anyone have any ideas?

[#]pyside #qt #pyqt

EDIT: This has been solved. See responses below.

=> View attached media | View attached media

=> More informations about this toot | More toots from chrishuck@fosstodon.org

Descendants

Written by Alyn on 2024-12-29 at 18:05

@chrishuck It's a very long time since I did anything in QT (Nokie N900 era), but is there a difference between ITEM.toggled and ITEM.selected or something like that? Or maybe an interaction between Python and QT, so Python handles the selection while QT handles the toggled state?

=> More informations about this toot | More toots from alyn@wandering.shop

Written by Chris Huck :freecad: :ubuntu: on 2024-12-29 at 18:23

@alyn Not sure. I’m no expert in it, but the documentation doesn’t seem super explicit in defining that parameter. There doesn’t seem to be any .selected() function defined for a radio button. 🤷‍♂️

=> More informations about this toot | More toots from chrishuck@fosstodon.org

Written by Jitse Niesen on 2024-12-30 at 09:50

@chrishuck I don't know FreeCAD, so this may not be relevant, but maybe you are talking about what Qt calls "focus"? You can give focus to the button with zbut.setFocus().

=> More informations about this toot | More toots from jitseniesen@mathstodon.xyz

Written by Chris Huck :freecad: :ubuntu: on 2024-12-30 at 12:48

@jitseniesen I’ll give it a shot! Thanks!

=> More informations about this toot | More toots from chrishuck@fosstodon.org

Written by Jeff Lange on 2024-12-31 at 12:05

@chrishuck A complete guess, but probably for keyboard selections, the first interact-able element having focus makes sense.

=> More informations about this toot | More toots from jefftml@toot.io

Written by elgregor@librem.one on 2024-12-31 at 14:51

@chrishuck No idea, but that highlight is called focus and QRadioButton seems to have some methods related to it.

=> More informations about this toot | More toots from elgregor@librem.one

Written by Chris Huck :freecad: :ubuntu: on 2024-12-31 at 14:55

@elgregor That is correct. The .setFocus() method does what I want, as mentioned in the reply above 👆 .

I looked for it in the Qt Python docs for QRadioButton, but I didn’t see any mention of that method. I thought I’d just missed it.

Thanks for relying!

=> More informations about this toot | More toots from chrishuck@fosstodon.org

Written by elgregor@librem.one on 2024-12-31 at 15:00

@chrishuck Glad it works. I don't see any replies other than mine. Either instances of other repliers don't want to federate with mine or my instance is just bugged.

=> More informations about this toot | More toots from elgregor@librem.one

Written by elgregor@librem.one on 2024-12-31 at 15:01

@chrishuck Oh, and Qt Python docs for QRadioButton might only list methods specific to QRadioButton, not the inherited ones.

=> More informations about this toot | More toots from elgregor@librem.one

Written by Chris Huck :freecad: :ubuntu: on 2024-12-31 at 15:09

@elgregor Thanks for the tips and the link to all of the members. I didn’t look up the tree to QWidget to see that it has the .setFocus() method that QRadioButton inherits. I learned something new today!

I’m more of a casual programmer that isn’t as fluent in how a lot of modern documentation is set up to figure out how to do what I want. I learn a little more each time, but I’d never done any real GUI programming for my FreeCAD macro until I wanted it for this new version.

=> More informations about this toot | More toots from chrishuck@fosstodon.org

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113737303425441550
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
444.375902 milliseconds
Gemini-to-HTML Time
3.733074 milliseconds

This content has been proxied by September (ba2dc).