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. QWidget not getting focus after canceling a QDialog...
Forum Updated to NodeBB v4.3 + New Features

QWidget not getting focus after canceling a QDialog...

Scheduled Pinned Locked Moved General and Desktop
17 Posts 2 Posters 5.8k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    First thing you should do is update Qt to 5.2. A lot of work has been done to add support for Mavericks

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

    1 Reply Last reply
    0
    • D Offline
      D Offline
      drhalftone
      wrote on last edited by
      #5

      I was unaware that 5.2.0 was available, but I'm afraid it did not help. I still have the issue with 5.2.0. I have an older mac that I will test this on Monday and see if there issue is there as well.

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

        If it's also the case, then you should try to create a minimal test program that reproduces the behavior to ensure it's a Qt bug

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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          drhalftone
          wrote on last edited by
          #7

          I haven't had a chance to make a test project yet, but I did narrow down the conditions that are causing it. I subclassed QDialog, and manually added an okay button. I then connected the clicked() signal from the button to the subclasses accept slot. I also overrode the closed() method, and if the dialog is closed, this method just calls the accept() method. If the user closes the dialog, then everything is fine. If the user clicks my accept button, then the window closes but the host window never gets focus.

          Any thoughts?

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

            Then you can make a little test app with just that: one widget, your minimal QDialog and what is needed to show it and trigger that behavior

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

            1 Reply Last reply
            0
            • D Offline
              D Offline
              drhalftone
              wrote on last edited by
              #9

              Okay here it is. Run the project. Click on the "Test Button", and it will bring up the QDialog with an QGLWidget. Hit either okay or cancel, and you will see that the QToolButtons in the original widget do not get activated even though they are the only window visible.

              Here is my .pro file:

              @#-------------------------------------------------

              Project created by QtCreator 2014-01-19T17:40:44

              #-------------------------------------------------

              QT += core gui opengl widgets

              TARGET = DialogError
              TEMPLATE = app

              SOURCES += main.cpp
              testwidget.cpp

              HEADERS += testwidget.h
              @

              Here is my header file:

              @#ifndef TESTWIDGET_H
              #define TESTWIDGET_H

              #include <QDebug>
              #include <QWidget>
              #include <QDialog>
              #include <QGroupBox>
              #include <QToolButton>
              #include <QGLWidget>
              #include <QHBoxLayout>
              #include <QVBoxLayout>
              #include <QPushButton>

              class TESTDialog : public QDialog
              {
              Q_OBJECT

              public:
              explicit TESTDialog(QWidget *parent = 0);
              ~TESTDialog();

              private:
              };

              class TESTWidget : public QWidget
              {
              Q_OBJECT

              public:
              explicit TESTWidget(QWidget *parent = 0);
              ~TESTWidget();

              public slots:
              void onPushButtonClicked();

              private:
              };

              #endif // TESTWIDGET_H
              @

              Here is my cpp file:

              @#include "testwidget.h"
              #include "ui_testwidget.h"

              TESTWidget::TESTWidget(QWidget *parent) : QWidget(parent)
              {
              this->setLayout(new QVBoxLayout());
              QGroupBox *box = new QGroupBox();
              box->setLayout(new QVBoxLayout());
              this->layout()->addWidget(box);

              QWidget *widget = new QWidget();
              widget->setLayout(new QHBoxLayout());
              
              QToolButton *button = new QToolButton();
              button->setText(QString("Test Button"));
              connect(button, SIGNAL(clicked()), this, SLOT(onPushButtonClicked()));
              
              widget->layout()->addWidget(button);
              widget->layout()->addWidget(new QToolButton());
              widget->layout()->addWidget(new QToolButton());
              widget->layout()->addWidget(new QToolButton());
              widget->layout()->addWidget(new QToolButton());
              
              box->layout()->addWidget(widget);
              

              }

              TESTWidget::~TESTWidget()
              {
              ;
              }

              void TESTWidget::onPushButtonClicked()
              {
              TESTDialog dialog;
              qDebug() << dialog.exec();
              }

              TESTDialog::TESTDialog(QWidget *parent) : QDialog(parent)
              {
              this->setLayout(new QVBoxLayout());
              QGLWidget *widget = new QGLWidget();
              widget->setMinimumSize(320,240);
              this->layout()->addWidget(widget);

              QPushButton *button = new QPushButton(QString("Accept"));
              connect(button, SIGNAL(clicked()), this, SLOT(accept()));
              this->layout()->addWidget(button);
              
              button = new QPushButton(QString("Cancel"));
              connect(button, SIGNAL(clicked()), this, SLOT(reject()));
              this->layout()->addWidget(button);
              

              }

              TESTDialog::~TESTDialog()
              {
              ;
              }
              @

              Look forward to your solution.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                drhalftone
                wrote on last edited by
                #10

                Given my success at recreating the bug in my test program, I decide to report the issue as a bug; however, I'd be thrilled to find a work around. Perhaps, you can suggest one?

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

                  I didn't had time to test so I can't right now

                  Can you post a link to your bug report please ?

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

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    drhalftone
                    wrote on last edited by
                    #12

                    https://bugreports.qt-project.org/browse/QTBUG-36268

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      drhalftone
                      wrote on last edited by
                      #13

                      I saw the comment that the code seems to work in 5.2.1, but I don't really want to mess with pre-release code and all the overhead of compiling, etc. Also, you have to look really closely at the tool buttons to notice that they aren't being re-activated dismissing the dialog.

                      Have you been able to test with 5.2.0 to confirm that you are seeing the issue in that release?

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

                        You don't need to build it yourself, you can use the pre-built 5.2.1 package

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

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          drhalftone
                          wrote on last edited by
                          #15

                          You'll have to remind me, how do I get the 5.2.1 binaries? The only binaries I see on the qt-project's download site is 5.2.0.

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

                            Sorry, I meant the snapshot you can find "here":http://download.qt-project.org/snapshots/qt/5.2/5.2.1/2014-02-02_42/qt-opensource-mac-x64-clang-5.2.1_2014-02-02_17-52-03-42.dmg the version from 02.02.2014

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

                            1 Reply Last reply
                            0
                            • D Offline
                              D Offline
                              drhalftone
                              wrote on last edited by
                              #17

                              Just tried the latest snapshot, but I'm afraid it's still not become active after accepting the dialog. So the bug remains.

                              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