I checked via Debug that the widget can be checked for visibility before raise().
When the widget is in the foreground then raise() will not be called.
So an extra test shouldn't hurt, here an example:
Code:
void MainWindow::FocusOnTOC()
{
FocusOn(m_TableOfContents);
m_TableOfContents->SetFocusOnTOC();
DBG qDebug() << "Focus";
if (m_TableOfContents->visibleRegion().isEmpty()) {
DBG qDebug() << "Here raise";
m_TableOfContents->raise();
}
ShowMessageOnStatusBar(tr("Focus changed to Table Of Contents window."));
}