PDA

View Full Version : Loosing Focus to PopUps



Abhishek Bansal
17th August 2012, 19:09
Hi All,

I am working on a application in which I am having a QMdiArea. In that QMdiArea i have multiple MdiSubWindows. Now when I Right Click a MDi SubWindow I get a PopUp that can can generate one more configuration menu as PopUp. Now My problem is after opening that second configuration menu if I want to activate another MdiSubWindow I have to click it 3 times. On Each Click one popup will go then in third click that MdiSubwindow will get activated. I want to do it in single Click

Now if i do not Open that second PopUp MdiSubwindow do not take 2 Click to get activated. It gets activated in single click.

I have tried doing ClearFocus in leaveEvent() of Mouse but its not helping.

In ui file both popups are Widgets.

Here is constructor of second popup

DMSControllerCustomizationMenu::DMSControllerCusto mizationMenu(QString sourceName, QWidget *parent)
{

if ( !_readUIFile())
{
LOG_ERROR("Unable to read the UI File")
return;
}

if ( !_initializeWidgets() )
{
LOG_ERROR ("Unable to initialize widgets. Check UI File");
return;
}



setWindowFlags(Qt::Popup);
setParent(parent);

hide();

_makeConnections();

QVBoxLayout *vBoxLayout = new QVBoxLayout();

vBoxLayout->addWidget(_customizationWidget);
vBoxLayout->setContentsMargins(0, 0, 0, 0);
vBoxLayout->setSpacing(o);

setWindowFlags(Qt::Popup);
// vBoxLayout->addWidget(_interpolationTypeDMSComboBox);
setLayout(vBoxLayout);
}


Here for first one..


if ( !_readUIFile())
{
LOG_ERROR("Reading UI Failed");
return;
}

_sourceName = sourceName;
if ( !_initializeWidgets())
{
LOG_ERROR("Unable to initialize widgets. Check UI File");
return;
}

_customizationSubWindow = new DMSControllerCustomizationMenu(sourceName, parent);
_customizationSubWindow->setVisible(false);

_makeConnections();

QHBoxLayout *hBoxLayout = new QHBoxLayout();

hBoxLayout->addWidget(_mainInputMenuWidget);
hBoxLayout->setContentsMargins(0, 0, 0, 0);
hBoxLayout->setSpacing(o);

setLayout(hBoxLayout);
resize(_mainInputMenuWidget->width(), _mainInputMenuWidget->height());

setParent(parent);
setWindowFlags(Qt::Popup);
setFocusPolicy(Qt::ClickFocus);
_menuFadeTimer.setSingleShot(true);
connect(&_menuFadeTimer, SIGNAL(timeout()), this, SLOT(hide()));
hide();