I have a QMenu objects to which I’ve added several QAction objects with a certain text. All works well, except that I would like to change the text of those QActions at runtime. I’ve looked at the QMenu API and didn’t find any way to to get them. I also tried actions.at(x) and a few other things. What’s the right way to do this?
Share
It really depends on how you are structuring your app. In some circumstances you might be saving your
QAction‘s as members, to which you could access directly. Or you might just be saving theQMenuand populating it withQAction‘s. Either way, once you have your action, you just callsetText(QString)on it:QMenualso allows you to look up actions by aQPointlocation. Again, it really depends on exactly how you will be determining which action you want to change.