QWidget not getting focus after canceling a QDialog...
-
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.
-
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
-
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?
-
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
-
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 = appSOURCES += main.cpp
testwidget.cppHEADERS += 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_OBJECTpublic:
explicit TESTDialog(QWidget *parent = 0);
~TESTDialog();private:
};class TESTWidget : public QWidget
{
Q_OBJECTpublic:
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.
-
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?
-
I didn't had time to test so I can't right now
Can you post a link to your bug report please ?
-
-
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?
-
You don't need to build it yourself, you can use the pre-built 5.2.1 package
-
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.
-
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
-
Just tried the latest snapshot, but I'm afraid it's still not become active after accepting the dialog. So the bug remains.