Important: Please read the Qt Code of Conduct -

QMenuBar lost focus when update QMenu.Title

  • Have QMenuBar with some QMenu items, one item periodicaly (per second) update title (QMenu.setTitle()), but with update, other QMenu items loss selection/focus... How to fix this?

    Есть QMenuBar с несколькими QMenu элементами, переодически (раз в секунду) у одного из элементов обновляется title (QMenu.setTitle()), однако при обновлении, другие элементы теряют выделение/фокус... Как пофиксить это?

    Update in slot:

    void ClockUpdated(QString time){
    // some code set value time

    @public slots:
    void DrawClock(QString time){

    QObject::connect(&WidgetFrame, SIGNAL(ClockUpdated(QString)), &MainWindow, SLOT(DrawClock(QString)));@

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    How do you update the menu title ?

  • Hi, thank you!
    Topic start updated.

  • Lifetime Qt Champion

    Your signal is wrong (that's not necessarily the problem). Signals don't have any implementation.

    You should try to ask on the interest mailing list if this is the intended behavior (the list is where you'll find Qt's developers/maintainers, this forum is more user oriented). It might be a bug (you could also check "the bug report system"

    In between, one thing you could do is to store who has the focus before the setTitle call and then set the focus again after setTitle.

    Hope it helps

  • Yes signal is wrong - this is abstract.
    I think about save and restore focus, but this more difficult and different in some OS's...

  • Lifetime Qt Champion

  • This working, but opened menu is blinking. Now how to fix blinking?

  • Lifetime Qt Champion

    That I don't know.

    But are you sure that updating a menu entry with the time is the correct approach ? Shouldn't you rather have a widget for that ?

Log in to reply