PDA

View Full Version : How set widget as current



Coder5546
29th November 2014, 11:31
Hi, when I trying to open QDialog or QWidget from other QWidget, opened widget is 'frozen' - not current, but when I close first widget, second widget is active.
How set new widget as current when is open from first widget ?

My code (first QWidget)


connect(mailbox, SIGNAL(tokenRequired(MailSystem*)), Token::getInstance(), SLOT(onTokenRequired(MailSystem*)));

End Token.h constructor


namespace Ui {
class Token;
}

class Token : public QWidget
{
Q_OBJECT

public:
explicit Token(QWidget *parent = 0);
static Token *getInstance()
{
static Token *instance = new Token;
return instance;
}
...
}

Regards

Lesiok
29th November 2014, 12:47
If first widget is modal this is normal behavior - it must be closed to activate another window.

If first widget is not modal then try this (line 14) :

namespace Ui {
class Token;
}

class Token : public QWidget
{
Q_OBJECT

public:
explicit Token(QWidget *parent = 0);
static Token *getInstance()
{
static Token *instance = new Token;
QApplication::setActiveWindow(instance);
return instance;
}
...
}

Coder5546
29th November 2014, 13:24
Thank You for Your reply.
I found the solution :)
Set window modality in Token