user63898
user63898

Reputation: 30885

How to make Qt QMainWindow to be in focus and overlay when clicked with the mouse when there is window overlay

i have Qmainwindow that opens with show() method another QMainWindow the problem is that when the second QMainwindow is on top the first one , when i click with the mouse on the first QMainWindow it doesn't return to be on top of the second windows. its getting the focus but doesn't go on top .. so its looks funny and not natural windowing behavior.

update ..
im using 2 QMainWindows . i know its not standard but i need the toolbar+ status bar of the window via the Designer.
any way in the 2 QMainWindows i don't have any properties set , i suspect this is where the solution . the code is simple in the main window i have member of another QMainWindow and in the main window i just do :

....  
ListWindow* m_pListWindow; // the second qmainwindow
......
void MainWindow::actionViewlistHandler()
{

    m_pListWindow->show();

}

Upvotes: 1

Views: 1604

Answers (1)

Mezo
Mezo

Reputation: 155

This happens when you give the 2nd MainWindow the first one as its parent

//This will cause the problem
MainWindow2 *m2 = new MainWindow2(this);
m2->show();

//This will solve your problem
MainWindow2 *m2 = new MainWindow2();
m2->show();

Upvotes: 2

Related Questions