I have a function that runs in the background and adds tabs in a QMdiArea. However, when a new tab is added it steals the focus from the currently active tab. Is there a way I can add a new inactive tab (sub window), so I keep the focus to the currently used tab? I have searched the web but was not able to find anything related to this issue.

I have tried the following:
Qt Code:
  1. MyWidget *widget=new MyWidget();
  2. QMdiSubWindow *sub=ui->mdiArea->addSubWindow(widget,Qt::SubWindow);
  3. sub->setWindowState(Qt::WindowNoState);
To copy to clipboard, switch view to plain text mode 
but it does not have the desired effect.