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();
}
}
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();
}
}
To copy to clipboard, switch view to plain text mode
In the constructor of the popup I have set a couple of flags:
setWindowFlags( Qt::Popup | Qt::MSWindowsFixedSizeDialogHint );
setWindowFlags( Qt::Popup | Qt::MSWindowsFixedSizeDialogHint );
To copy to clipboard, switch view to plain text mode
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
Bookmarks