简体   繁体   中英

QSizeGrip and Qt::Popup

When I add a QSizeGrip to a widget (like QWidget or QDialog ) and then enable the Qt::Popup window flag, the size grip does not work anymore.

Why so?

I would like to create a resizeable borderless popup window, like the one used in QCompleter . Setting the Qt::FramelessWindowHint flag seems to make it borderless but the focus behaviour is quite different..

After reading through the Qt sources, I found two possible solutions, kind of.

Basically, the QSizeGrip provides a basic implementation that is perfectly fine and works even when Qt::Popup is set or when the window is borderless for other reasons. However, Qt tries to use a platform specific mechanism to offer the size grip.

At least unter Linux/X11 this mechanism seems to fail when the Qt::Popup flag is set.

The idea is to bypass using the platform specific mechanism and always use the basic implementation (aka Qt's fallback). This is achieved by either

  • setting the Qt::BypassWindowManagerHint flag or
  • re-implementing QWidget::hasHeightForWidth() to return true (and appropriately provide a neutral Qt::heightForWidth() ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM