QT Implementation window zoom open and close (overlapping window, too interesting)

Source: Internet
Author: User

Basic idea: Suppose A is the main window and B is a child window. A on or off, the a window first, and then the picture is full of the whole b window, in the PaintEvent to dynamically zoom or enlarge the drawing. Finally, using animation, the b window is animated to open or close, after the animation has finished, B sends a signal to a, a, a display.

The core code is sent:

In a window:

Qpixmap Pixmap;

Ctestdialog Dlg (this);
Dlg. Setpixmap (Pixmap.grabwidget (this));
Hide ();
Dlg.exec ();

b window:

Ctestdialog::ctestdialog (Qwidget *pparent): Qdialog (pparent)
{
UI.SETUPUI (this);
Setwindowflags (Qt::D ialog | Qt::framelesswindowhint);
}

Ctestdialog::~ctestdialog ()
{
}

void Ctestdialog::setpixmap (const qpixmap &PIXMAP)
{
M_backpixmap = Pixmap;
M_image = Pixmap.toimage ();
Update ();

Qdesktopwidget *desktopwidget = qapplication::d esktop ();
Qrect screenrect = Desktopwidget->screengeometry ();

Qpropertyanimation *animation = new Qpropertyanimation (This, "geometry");
Animation->setduration (2200);
Animation->seteasingcurve (qeasingcurve::outbounce);
Animation->setstartvalue (Qrect ((Screenrect.width ())/2, (Screenrect.height ()-50)/2, 50, 50));
Animation->setendvalue (Qrect ((Screenrect.width ()-$)/2, (Screenrect.height ()-400)/2, 500, 400));
Animation->start ();
}

void Ctestdialog::p aintevent (qpaintevent *p)
{
Qpalette Pal (palette ());
Pal.setbrush (Qpalette::window, Qbrush (m_image.scaled (This->size (), Qt::ignoreaspectratio, Qt:: (smoothtransformation)));
SetPalette (PAL);
}

http://blog.csdn.net/itjobtxq/article/details/9663757

QT Implementation window zoom open and close (overlapping window, too interesting)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.