I've been struggling with a little problem.
Basically I have one application with two windows: WindowA and WindowB. WindowA is sort of like the main window while WindowB is a window with some buttons in it.
What I want to do is to have WindowA permanently be the activated (focused) window. So whenever I click on a button inside WindowB - WindowA should stay activated/focused.
Currently, when clicking on any button inside WindowB, it gets activated/focused.
What I've tried so far:
bool WindowB
::event(QEvent *event
) {
if(event
->type
() == QEvent::WindowActivate) {
event->accept();
m_windowA->activate();
return true;
}
}
//This actually works quite well.
//However, clicking on any controls won't work
//(WindowB doesn't receive mouseReleaseEvent()'s :().
bool WindowB::event(QEvent *event)
{
if(event->type() == QEvent::WindowActivate)
{
event->accept();
m_windowA->activate();
return true;
}
return QWidget::event(event);
}
//This actually works quite well.
//However, clicking on any controls won't work
//(WindowB doesn't receive mouseReleaseEvent()'s :().
To copy to clipboard, switch view to plain text mode
m_windowB->setFocusPolicy(Qt::NoFocus);
//Doesn't work at all (for my scenario).
m_windowB->setFocusPolicy(Qt::NoFocus);
//Doesn't work at all (for my scenario).
To copy to clipboard, switch view to plain text mode
m_windowB->setFocusProxy(m_windowA);
//I thought this was it, but somehow it didn't change anything in behavior.
m_windowB->setFocusProxy(m_windowA);
//I thought this was it, but somehow it didn't change anything in behavior.
To copy to clipboard, switch view to plain text mode
void WindowB
::mousePress/*Release*/Event
(QMouseEvent *event
) {
QWidget::mousePress/*Release*/Event
(event
);
m_windowA->activate();
}
//This works, but it seems like too much of a dirty workaround.
//Isn't there a more elegant solution?
void WindowB::mousePress/*Release*/Event(QMouseEvent *event)
{
QWidget::mousePress/*Release*/Event(event);
m_windowA->activate();
}
//This works, but it seems like too much of a dirty workaround.
//Isn't there a more elegant solution?
To copy to clipboard, switch view to plain text mode
Bookmarks