Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6965565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:04:40+00:00 2026-05-27T16:04:40+00:00

When you save a file on a Mac, a panel kinda descends down from

  • 0

When you save a file on a Mac, a panel kinda descends down from the top bar in a really cool way. I want to create a class that does a similar thing using the Qt framework. There are a number of things that I’m confused about:

  1. When the panel descends, input to the parent window should be blocked. This is easy with QDialog as it has the setModal() method, however – QDialogs, by default pop-out. I’m not sure how to get around this.

  2. In a QMainProject, there is a QMenua new instance of the DescendingPanel class is created. How would you do that, supposing there are other widgets below the menubar. The DescendingPanel should appear above them.

I would really appreciate any help with this.

EDIT

I had an idea that instead of pegging the dialog under the menubar, just make it appear under there and remove the window frame. That way, it would give an illusion that it popped out from under there. Ofcourse, Move events would also have to be handled so that the Dialog is always under the menubar but that’s for later. Here’s the code I used to get the DescendingDialog to appear under the menubar.

class DescendingDialog : public QWidget
{
    QMainWindow* Window;
    QWidget*     Menu;
    QPoint       GlobalLocationOfMenu;
    int          DialogWidth;
    int          DialogHeight;

    int X()
    {
        int XDistanceOfPanel = GlobalLocationOfMenu.x() + ((Menu->width()/2) - (this->DialogWidth/2));
        //GlobalLocationOfMenu.x() returns 0;
        return XDistanceOfPanel;
    }

    int Y()
    {
        int YDistanceOfPanel = GlobalLocationOfMenu.y()+Menu->height();
        //GlobalLocationOfMenu.y() returns 0;
        return YDistanceOfPanel;
    }

    void SetGeometry()
    {
        this->setGeometry(this->X(),this->Y(),this->DialogWidth,this->DialogHeight);

    }
public:
    DescendingDialog(QMainWindow*   Window,int DialogWidth,int DialogHeight):QWidget(NULL)
    {
       this->Window = Window;
       this->Menu   = this->Window->menuWidget();
       this->DialogWidth = DialogWidth;
       this->DialogHeight = DialogHeight;

       QPoint RelativeLocationOfMenu = this->Menu->pos();
       this->GlobalLocationOfMenu = QWidget::mapToGlobal(RelativeLocationOfMenu);
       this->SetGeometry();

    }
};

It didn’t work because the GlobalLocationOfMenu.x() and .y() returned 0 so the dialog doesn’t appear where I want it to.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:04:41+00:00Added an answer on May 27, 2026 at 4:04 pm

    You can let a dialog “slide in” by using a function similar to that:

    #include <QDialog>
    #include <QPropertyAnimation>
    #include <QParallelAnimationGroup>
    
    void makeAppear(QDialog * dialog, QRect geometryEnd)
    {
        static QParallelAnimationGroup *animationGroup = 0;
        if (animationGroup)
        {
            for(int i = 0, ie = animationGroup->animationCount(); i != ie; ++i)
                delete animationGroup->animationAt(i);
            delete animationGroup;
        }
    
        // Set up start and end geometry for 'dialog'.
        QPoint parentTopLeft = dialog->parentWidget()->geometry().topLeft();
        geometryEnd.translate(dialog->parentWidget()->mapToGlobal(parentTopLeft));
        QRect geometryBegin = geometryEnd;
        geometryBegin.setHeight(0);
    
        // Set up start and end geometry for the only child widget of 'dialog'.
        QWidget * dialogChildWidget = dynamic_cast< QWidget * >(dialog->children().first());
        if ( !dialogChildWidget )
            return;
        QRect childGeometryEnd = dialogChildWidget->geometry();
        QRect childGeometryBegin = childGeometryEnd;
        childGeometryBegin.translate(0, geometryEnd.height() * (-1));
    
        // Set up animation for 'dialog'.
        QPropertyAnimation *dialogAnimation = new QPropertyAnimation(dialog, "geometry");
        dialogAnimation->setDuration(400);
        dialogAnimation->setStartValue(geometryBegin);
        dialogAnimation->setEndValue(geometryEnd);
    
        // Set up animation for the only child widget of 'dialog'.
        QPropertyAnimation *childAnimation = new QPropertyAnimation(dialogChildWidget, "geometry");
        childAnimation->setDuration(400);
        childAnimation->setStartValue(childGeometryBegin);
        childAnimation->setEndValue(childGeometryEnd);
    
        // Set up (and start) a parallel animation group
        animationGroup = new QParallelAnimationGroup;
        animationGroup->addAnimation(dialogAnimation);
        animationGroup->addAnimation(childAnimation);
        animationGroup->start();
    
        // Make 'dialog' visible, borderless, modal.
        dialog->setModal(true);
        dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
        dialog->show();
    }
    

    The dialog argument shall point to a (hidden/not visible) QDialog instance with one single child widget, that contains all other widgets that belong to the dialog.

    The geometryEnd argument shall specify position and size of dialog after it has appeared (relative to it’s parent widget).

    The result looks like this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to save a file in a way that opening
I want to open a save file dialog, have the user enter a filename,
Can the save as file name be entered automatically into the save dialog(from a
Using Mac OS X API, I'm trying to save a PDF file with a
I want to save my currently database on localhost to file. I am trying
When I save a TSV file in windows from excel, it uses the line
This question is related to the previous post. How to save file and read
When I save a file with an .htm or .html extension, which one is
When I save a file 'last saved' date time in a SQL database, I
How to save text file content to different arrays? my text file content is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.