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. Combobox and menu not closed when switching windows
Forum Updated to NodeBB v4.3 + New Features

Combobox and menu not closed when switching windows

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 212 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    sprkxr
    wrote on last edited by
    #1

    Hi
    I have written a qt toolbar with QCombobox and control menu on MAC. But when I switch windows, I find that the QCombobox options and popup submenus are always at the top of the screen and do not collapse automatically. I've tried adding close QCombobox and menu after losing focus, but it doesn't work.
    How to solve this problem?
    Thanks!

    QT 5.15.12
    MacOS 14.0.0

    The code is:
    MyQComboBox::MyQComboBox(QWidget *parent) : QComboBox(parent)
    {
    this->setView(new QListView());
    this->setStyle(QStyleFactory::create("Windows"));
    this->view()->window()->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
    this->view()->window()->setAttribute(Qt::WA_TranslucentBackground);
    }

    SkinComboBox = new MyQComboBox();
    SkinComboBox->setObjectName("SkinComboBox");
    SkinComboBox->addItem(tr("widget.settings.skin.light"));
    SkinComboBox->addItem(tr("widget.settings.skin.dark"));

    M 1 Reply Last reply
    0
    • S sprkxr

      Hi
      I have written a qt toolbar with QCombobox and control menu on MAC. But when I switch windows, I find that the QCombobox options and popup submenus are always at the top of the screen and do not collapse automatically. I've tried adding close QCombobox and menu after losing focus, but it doesn't work.
      How to solve this problem?
      Thanks!

      QT 5.15.12
      MacOS 14.0.0

      The code is:
      MyQComboBox::MyQComboBox(QWidget *parent) : QComboBox(parent)
      {
      this->setView(new QListView());
      this->setStyle(QStyleFactory::create("Windows"));
      this->view()->window()->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
      this->view()->window()->setAttribute(Qt::WA_TranslucentBackground);
      }

      SkinComboBox = new MyQComboBox();
      SkinComboBox->setObjectName("SkinComboBox");
      SkinComboBox->addItem(tr("widget.settings.skin.light"));
      SkinComboBox->addItem(tr("widget.settings.skin.dark"));

      M Offline
      M Offline
      mpergand
      wrote on last edited by mpergand
      #2

      Hi @sprkxr

      It's an old bug on Mac.
      The assertion that Qt doesn't have to care of what happens outside of windows is wrong on mac, because of the presence of the main menu bar on top of the screen.

      Have a try with Qt6, things have changed in this area.

      [EDIT] the bug when switching window/app exists on early version of Qt5, but not on Qt 15 in my experience, only the bug with the main menu bar persists.

      I'm using Qt15 with QTCreator compiled with Qt6 and the bug with the main menu bar is corrected.

      1 Reply Last reply
      2
      • S Offline
        S Offline
        sprkxr
        wrote on last edited by
        #3

        Thanks very much!
        I can't upgrade the QT version yet.
        It seems that this problem can only be solved by replacing the QT6 in the future.
        Thanks again!

        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