mercredi 8 février 2017

How to resize a QWidgetAction after changing it's contents

Vote count: 0

I use a QWidgetAction to add a header to a context menu (that will also show up on Windows, no matter what style is used, in contrast to addSection(), which does not always actually display the title).

The action's widget is a QLabel. It's text is changed by each invocation of the context menu.

When the label's text is set for the first time, everything is fine:

enter image description here

but when it's set to some longer text, the size remains the same and the text is cropped:

enter image description here

I tried to fix this, but the only working solution I found was to call QMenu::clear(), construct a new QWidgetAction with a new QLabel and re-add the other actions.

Is there a way to resize the title without rebuilding the menu each time?

asked 35 secs ago

Let's block ads! (Why?)



How to resize a QWidgetAction after changing it's contents

Aucun commentaire:

Enregistrer un commentaire