Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Does Qt support Mac-style pop-out widgets?

Does Qt support Mac-style pop-out widgets?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 2.1k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jdxjohn
    wrote on last edited by
    #1

    I am not a Mac developer does anyone know what these kind of controls are called:
    0_1547122252072_ef9f48e7-6d2a-424c-8a58-aadd58201e7c-image.png

    Here this pops out from a button and is able to extend beyond the parent/main window, but if you click outside the popout widget it automatically disappears. I'm not familiar with this kind of toolbar widget in WinAPI and as we're developing a cross-platform application based on an existing Mac application, I'd like to know if Qt can provide something similar/use these native widgets in a cross-platform way?

    Thanks.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jdxjohn
      wrote on last edited by
      #2

      OK so in Mac speak these are "popovers" https://developer.apple.com/design/human-interface-guidelines/macos/windows-and-views/popovers/

      Does Qt support them, and if so what is the Windows equivalent? If not, what is the closest cross-platform alternative - it's just neat they disappear when you click away.

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        Qt do not have such control/widget. (as far as i know)
        For a cross platform solution, i think you would have to make a custom widget.
        Technically its similar to a QComboBox that also allows to go out side parents area and
        will close on click outside. It uses a event filter to be able to close if click outside.

        alt text

        so you could go dig around in its code
        https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qcombobox.cpp.html

        to be inspired.
        Basically it would be a frame less floating window and some eventfilter to
        obtain a similar effect.

        1 Reply Last reply
        3
        • M Offline
          M Offline
          mpergand
          wrote on last edited by mpergand
          #4

          You can make your own custom widget based on Qt::PopUp window flag.
          Here my own widget constructor:

          static const int ArrowSize=13;
          
          PopupWindow::PopupWindow(QWidget *parent) : QWidget(parent)
          {
              setWindowFlags(Qt::FramelessWindowHint|Qt::NoDropShadowWindowHint|Qt::Popup);
              setAttribute(Qt::WA_TranslucentBackground);
              setContentsMargins(ArrowSize+1,ArrowSize+1,ArrowSize+1,ArrowSize+1);
          
              oContentWidget=new ContentWidget(this);
              oContentWidget->setMinimumSize(QSize(100,100));
              oContentWidget->move(ArrowSize+1,ArrowSize+1);
              oContentWidget->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
          
               // widget shadow
              pShadowEffect = new QGraphicsDropShadowEffect();
              pShadowEffect->setBlurRadius(18);
              pShadowEffect->setColor(ShadowColor[ShadowColor_Active]);
              pShadowEffect->setOffset(QPoint(1,4));
              setGraphicsEffect(pShadowEffect);
          }
          

          You need to define an AnchorPoint and a AnchorWidget to position the popup correctly. For ex:

          void PopupWindow::showWithAnchor(QWidget* anchorWidget, Qt::AnchorPoint anchorPt)
          {
          ...
          }
          

          Some work required ;)

          0_1547130948057_PopUpWindow.png

          1 Reply Last reply
          3
          • J Offline
            J Offline
            jdxjohn
            wrote on last edited by
            #5

            Thanks, this is most helpful. It seems this is a Mac-native control so it makes sense Qt doesn't support directly.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              It's a NSPopover. However you might be able to integrate it into your Qt application.

              Here you have an example on how to show on programmatically using Objective-C.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved