PDA

View Full Version : How to make window semi modal



kaushal_gaurav
27th August 2008, 08:21
Hi,

Consider the senario....

There is a Push Button showWindow to Display a window on the Screen.
When window is shown the PushButton Lable changes to HideWindow() and when i click on it
the window is hidden again.

Now this means the window need to be nonModal... and i can not call exec().

but now window is gets hidden when i click on the parent (it is not closed just hides under the parent window - which is full screen).

Is there a way to make this window 'always on top' and still it to be non modal?

Please help.............

kaushal_gaurav
27th August 2008, 10:53
Is there no solution available....

I just need a window to be always on top and be able to send inputs to parent dialog also.

wysota
27th August 2008, 13:00
Set the parent of the child dialog. Children are always on top of their parents, so clicking the parent will not cause it to be raised above the child.

aamer4yu
27th August 2008, 13:02
Will setWindowFlags(Qt::WindowStaysOnTopHint) help you ?

kaushal_gaurav
28th August 2008, 04:56
setWindowFlags(Qt::WindowStaysOnTopHint) does not help...By using it the window is not even displayed..

I have already passed the parent in the constructor while creating the widget.

Problem not solved.... Help....

wysota
28th August 2008, 13:50
You mean this doesn't work for you?


#include <QtGui>

int main(int argc, char **argv){
QApplication app(argc, argv);
QTextEdit te;
QDialog *dlg = new QDialog(&te);
QVBoxLayout *l = new QVBoxLayout(dlg);
l->addWidget(new QPushButton);
te.show();
// te.showFullScreen(); // works as well
dlg->show();
return app.exec();
}
Do you see the child dialog when you click the parent?

kaushal_gaurav
29th August 2008, 05:07
This isn' t the code .
I try to explain... I have a dialog derived from QGraphicsItem and QDialog. It has "Show" button. That button brings up another dialog and the button lable changes to "Hide".
Now i need to close the newly opened dialog to be closed by clicking "Hide" button in parent dialog. Now the problem is, when i click any where on the application the newly opened dialog goes behind - which is not what i want.



void MainDilaog::HandleShowhideButton()
{
if (m_ChannelsDlg->isVisible())
{
m_ChannelsDlg->close();
showButton.setText(tr("Show"));
}
else
{
showButton.setText(tr("Hide"));
m_ChannelsDlg->setWindowFlags(flags);
m_ChannelsDlg->show();
}


MainDilaog is derived from QGraphicsItem and QDialog.

GK

wysota
29th August 2008, 08:27
Could you prepare a minimal compilable example reproducing the problem?