Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 6.8 and ShowEvent being called twice
Forum Updated to NodeBB v4.3 + New Features

Qt 6.8 and ShowEvent being called twice

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 141 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Fred_1234
    wrote on last edited by Fred_1234
    #1

    I was trying to set some stuff up that needed to be done once the display is actually open, so I initially had the code in

    void Foo::showEvent(QShowEvent * event)
    {
      QDialog::showEvent(event);
      qDebug()<<"test";
      QTimer::singleShot(0, this, &Foo::doStuff);
    }
    

    doStuff throws up some more GUI items that take focus. Everything was working as expected with Qt6.5 and lower, and "test" is printed out once.

    On the upgrade to Qt6.8, "test" is now printed out twice, and the dialog has focus rather than the child controls which I was trying to give focus too.

    This is on Red Hat 8.

    Is there a better way now to do stuff that will be executed after the dialog is officially shown? And is showEvent now going to be called multiple times, rather than once?

    (Even if I remove everything, so it's just the dialog constructor and showEvent, the constructor is called once, whereas showEvent is called twice.)

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Doing such stuff in showEvent() is not a good idea - it is e.g. also called when the window is minimized and restored. Why it happens in your case - I don't know. Maybe you can find out by looking at the backtrace during debugging. Maybe set a flag in doStuff to do it only once.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved