M
M
maaGames2022-01-03 10:03:27
Qt
maaGames, 2022-01-03 10:03:27

How NOT to inherit styles?

There are groups of differently styled buttons. There are a lot of buttons. Now I apply styles through an explicit listing of QPushButton#name names, but this is difficult to maintain and generally inconvenient.
There is an idea for each type of buttons to inherit a dummy class and set the style for specific classes through promote. In general, this is convenient in terms of programming, but inconvenient for visual editing. The style is displayed in the designer only for the original QPushButton, and styles are not displayed for overridden classes, which is very inconvenient. At the same time, it is impossible to style QPushButton, because its styles are inherited by all child classes, and if this is not necessary, then the styles will have to be redefined for each child class, which makes the styling of the base class meaningless.
Is there any other way to sit on two chairs and not choke on a bone? Conventionally, there are 50 QPushButtons with three different styles, and I don't want to set each of them three times through #name (+ hover + pressed).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jacob E, 2022-01-03
@maaGames

Your question is too vague to answer unequivocally, but try to implement three different button classes by giving them the same prefixes within the class: https://stackoverflow.com/a/49649227

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question