Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Unsolved Does Qt support Mac-style pop-out widgets?

    General and Desktop
    4
    6
    957
    Loading More Posts
    • 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
      jdxjohn last edited by

      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 Reply Quote 0
      • J
        jdxjohn last edited by

        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 Reply Quote 0
        • mrjj
          mrjj Lifetime Qt Champion last edited by

          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 Reply Quote 3
          • M
            mpergand last edited by mpergand

            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 Reply Quote 3
            • J
              jdxjohn last edited by

              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 Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 Reply Quote 2
                • First post
                  Last post