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. QWidgetAction on MacOS creates additional empty dialog windows when activated!?

QWidgetAction on MacOS creates additional empty dialog windows when activated!?

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 2.7k 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.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi,
    I am testing my first Qt app on MacOS 10.12, and again have some strange things happening that don't happen in Windows.

    I have several Menu items which are of the type QWidgetAction and which mostly contain a QComboBox from which I can select preset values.

    I know that QWidgetAction comes with some restrictions on MacOS X, but that it should basically work.

    However, on MacOS, whenever I first activate such a QWidgetAction, a small, empty, translucent dialog box pops up which does not close, unless I click on the close button of that dialog. After I close the dialog, it does not reappear for that menu item. However, other menu items of the type QWidgetAction will still spawn such empty dialog windows. I can end up with several of these at the same time...

    0_1517742686598_MacOS X QWidgetAction.png

    Furthermore, at the second activation of such a QComboBox in a QWidgetAction, the contents of the combo box only show when clicked upon; if not clicked, it only shows an empty rectangle.

    0_1517742702373_MacOS X QWidgetAction Empty.png

    What is the correct way on MacOS X to add a combo box menu item to the main application menu, since QWidgetAction does not seem to work correctly?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Please provide a minium compilable example that reproduces this behaviour.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      DiracsbracketD 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Please provide a minium compilable example that reproduces this behaviour.

        DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by Diracsbracket
        #3

        @SGaist
        Created Qt application, with single form and added QMenu Settings to menubar via Qt Designer. Then, still in Qt Designer, added a submenu menuTest to Settings.

        After this, the auto-generated ui_mainwindow.h file looks as follows:

        #ifndef UI_MAINWINDOW_H
        #define UI_MAINWINDOW_H
        
        #include <QtCore/QVariant>
        #include <QtWidgets/QAction>
        #include <QtWidgets/QApplication>
        #include <QtWidgets/QButtonGroup>
        #include <QtWidgets/QHeaderView>
        #include <QtWidgets/QMainWindow>
        #include <QtWidgets/QMenu>
        #include <QtWidgets/QMenuBar>
        #include <QtWidgets/QStatusBar>
        #include <QtWidgets/QToolBar>
        #include <QtWidgets/QWidget>
        
        QT_BEGIN_NAMESPACE
        
        class Ui_MainWindow
        {
        public:
            QAction *actionSub;
            QWidget *centralWidget;
            QMenuBar *menuBar;
            QMenu *menuSettings;
            QMenu *menuTest;
            QToolBar *mainToolBar;
            QStatusBar *statusBar;
        
            void setupUi(QMainWindow *MainWindow)
            {
                if (MainWindow->objectName().isEmpty())
                    MainWindow->setObjectName(QStringLiteral("MainWindow"));
                MainWindow->resize(400, 300);
                actionSub = new QAction(MainWindow);
                actionSub->setObjectName(QStringLiteral("actionSub"));
                centralWidget = new QWidget(MainWindow);
                centralWidget->setObjectName(QStringLiteral("centralWidget"));
                MainWindow->setCentralWidget(centralWidget);
                menuBar = new QMenuBar(MainWindow);
                menuBar->setObjectName(QStringLiteral("menuBar"));
                menuBar->setGeometry(QRect(0, 0, 400, 22));
                menuSettings = new QMenu(menuBar);
                menuSettings->setObjectName(QStringLiteral("menuSettings"));
                menuTest = new QMenu(menuSettings);
                menuTest->setObjectName(QStringLiteral("menuTest"));
                MainWindow->setMenuBar(menuBar);
                mainToolBar = new QToolBar(MainWindow);
                mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
                MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar);
                statusBar = new QStatusBar(MainWindow);
                statusBar->setObjectName(QStringLiteral("statusBar"));
                MainWindow->setStatusBar(statusBar);
        
                menuBar->addAction(menuSettings->menuAction());
                menuSettings->addAction(menuTest->menuAction());
        
                retranslateUi(MainWindow);
        
                QMetaObject::connectSlotsByName(MainWindow);
            } // setupUi
        
            void retranslateUi(QMainWindow *MainWindow)
            {
                MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", Q_NULLPTR));
                actionSub->setText(QApplication::translate("MainWindow", "Sub", Q_NULLPTR));
                menuSettings->setTitle(QApplication::translate("MainWindow", "Settings", Q_NULLPTR));
                menuTest->setTitle(QApplication::translate("MainWindow", "Test", Q_NULLPTR));
            } // retranslateUi
        
        };
        
        namespace Ui {
            class MainWindow: public Ui_MainWindow {};
        } // namespace Ui
        
        QT_END_NAMESPACE
        
        #endif // UI_MAINWINDOW_H
        

        From this point on:

        #ifndef MAINWINDOW_H
        #define MAINWINDOW_H
        
        #include <QMainWindow>
        #include <QComboBox>
        
        namespace Ui {
        class MainWindow;
        }
        
        class MainWindow : public QMainWindow
        {
            Q_OBJECT
        
        public:
            explicit MainWindow(QWidget *parent = 0);
            ~MainWindow();
        
        private:
            Ui::MainWindow *ui;
            QComboBox* m_testComboBox;
        };
        
        #endif // MAINWINDOW_H
        

        The source file:

        #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        #include <QWidgetAction>
        
        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        
        
            m_testComboBox = new QComboBox(ui->menuTest);
            for (int i=0; i<10; ++i)
                m_testComboBox->addItem(QString::number(i), QVariant(i));
        
            QWidgetAction* testAction = new QWidgetAction(ui->menuTest);
            testAction->setDefaultWidget(m_testComboBox);
            ui->menuTest->addAction(testAction);
        }
        
        MainWindow::~MainWindow()
        {
            delete ui;
        }
        

        Result:
        The ghost dialog window is spawned when the Test submenu is activated (combobox not yet triggered).

        0_1517800104877_Minimal_QWidgetAction.png

        The contents of the QComboBox only appear when clicked on it + shows an empty rectangle behinds it.

        0_1517800145736_Minimal_QWidgetAction2.png

        I realize the Qt Framework is an extremly complex and large undertaking, but these sorts of things are a little bit tiring, for an unskilled amateur programmer like myself...
        Of course, I cannot rule out that all these problems (there are others, but this one seems to be a pure GUI issue rather than HW related such as Audio or Mouse) I am facing with porting to MacOS X may be due to the fact that I am using a VM rather than a physical MacOS machine...

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mpergand
          wrote on last edited by
          #4

          I confirm, it's completly buggy on Mac (10.9.5 for me) and unusable.
          0_1517844303198_WidgetAction bug.png
          I don't see any ghost window though.

          DiracsbracketD 1 Reply Last reply
          2
          • M mpergand

            I confirm, it's completly buggy on Mac (10.9.5 for me) and unusable.
            0_1517844303198_WidgetAction bug.png
            I don't see any ghost window though.

            DiracsbracketD Offline
            DiracsbracketD Offline
            Diracsbracket
            wrote on last edited by Diracsbracket
            #5

            @mpergand said in QWidgetAction on MacOS creates additional empty dialog windows when activated!?:

            I don't see any ghost window though.

            Are you using a MacOS X Virtual Machine (mine is VMware Player)?

            M 1 Reply Last reply
            0
            • DiracsbracketD Diracsbracket

              @mpergand said in QWidgetAction on MacOS creates additional empty dialog windows when activated!?:

              I don't see any ghost window though.

              Are you using a MacOS X Virtual Machine (mine is VMware Player)?

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

              @Diracsbracket said in QWidgetAction on MacOS creates additional empty dialog windows when activated!?:

              Are you using a MacOS X Virtual Machine (mine is VMware Player)?

              No, it's a real Mac.
              Anyway, i don"t see any advantage of a combo over a list of menu items here.
              To avoid possible issues, it's advisable to do simplest things as much as possible. (in particular if you're targeting MacOS) IMHO

              DiracsbracketD 2 Replies Last reply
              1
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                I'm not getting any ghost Windows with my Qt 5.10 build on macOS 10.12.6 however there are some focus issue.

                In any case, I agree with @mpergand a combo box is pretty unusual in an application menu. A checkable action is more likely to be in the user expectation.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                DiracsbracketD 1 Reply Last reply
                0
                • M mpergand

                  @Diracsbracket said in QWidgetAction on MacOS creates additional empty dialog windows when activated!?:

                  Are you using a MacOS X Virtual Machine (mine is VMware Player)?

                  No, it's a real Mac.
                  Anyway, i don"t see any advantage of a combo over a list of menu items here.
                  To avoid possible issues, it's advisable to do simplest things as much as possible. (in particular if you're targeting MacOS) IMHO

                  DiracsbracketD Offline
                  DiracsbracketD Offline
                  Diracsbracket
                  wrote on last edited by
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • SGaistS SGaist

                    I'm not getting any ghost Windows with my Qt 5.10 build on macOS 10.12.6 however there are some focus issue.

                    In any case, I agree with @mpergand a combo box is pretty unusual in an application menu. A checkable action is more likely to be in the user expectation.

                    DiracsbracketD Offline
                    DiracsbracketD Offline
                    Diracsbracket
                    wrote on last edited by Diracsbracket
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • M mpergand

                      @Diracsbracket said in QWidgetAction on MacOS creates additional empty dialog windows when activated!?:

                      Are you using a MacOS X Virtual Machine (mine is VMware Player)?

                      No, it's a real Mac.
                      Anyway, i don"t see any advantage of a combo over a list of menu items here.
                      To avoid possible issues, it's advisable to do simplest things as much as possible. (in particular if you're targeting MacOS) IMHO

                      DiracsbracketD Offline
                      DiracsbracketD Offline
                      Diracsbracket
                      wrote on last edited by Diracsbracket
                      #10

                      @mpergand said in QWidgetAction on MacOS creates additional empty dialog windows when activated!?:

                      To avoid possible issues, it's advisable to do simplest things as much as possible. (in particular if you're targeting MacOS) IMHO

                      Hi,
                      Since the QWidgetAction did definitely not work correctly on MacOS X (although Qt 5.10 has an improvement as @SGaist mentioned), I heeded your advice and spent the day replacing all the QWidgetActions by QActions in a QActionGroup, and I must say, it looks much better. More importantly, it works on both Windows and MacOS X.

                      Cheers!0_1518047993651_Screen Shot 2018-02-07 at 3.58.04 PM.png

                      Although the original issues of ghost windows et al. are not really solved, at least on Qt 5.9.4, I will put this question as solved nonetheless. The answer is simply: don't use QActionWidget in the application menu.

                      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