PDA

View Full Version : Can't close my popup



Jimmy2775
6th July 2006, 18:59
I have created a widget that has a QToolButton that, when clicked, calls the following slot:

void ParentWidget::ButtonClickedSlot()
{
// If already shown then hide the popup
if( !mMyPopup->isHidden() )
{
mMyPopup->hide();
}
else
{
// Build the Rect and show the window
QRect newRect( x, y, mDropWidth, mDropHeight );
mMyPopup->setGeometry( newRect );
mMyPopup->show();

}
}

In the constructor of the popup I have set a couple of flags:

setWindowFlags( Qt::Popup | Qt::MSWindowsFixedSizeDialogHint );

When I first click the button, the popup pops up as expected. If I click anywhere in the application, the popup hides (I think this is the result of having set the Qt::Popup flag because I didn't write any code to cause the popup to hides that way). The problem I am having is that if I click on the QToolButton when the popup is open already, the click causes the popup to hide, and then the ButtonClickedSlot is called which causes the popup to show again.

I've worked at this one for a while but I don't seem to be making any progress. Any suggestions would be greatly appreciated.

James

Jimmy2775
10th July 2006, 23:46
Perhaps a better way to phrase my quesiton is this:

I'd like to be able to toggle a popup open/closed using a button. I can get it to open, but I can't get it to close.

Any ideas on how I can fix this, or an alternative approach, would be greatly appreciated.

zlatko
11th July 2006, 09:10
I think you can cut Qt::Popup flag and do show/hide yourself :rolleyes: