Hidden display and movement of QT5 controls

Source: Internet
Author: User

This routine implements the hiding, display, and movement of controls.

Basic technologies such as signals and slots for controls are no longer cumbersome and go directly to key technology points:

In this routine, when the button is pressed, the list box moves up, the control between the button and the list box is hidden, and when the button is pressed again, the list box moves down, and the button is displayed with the control between the list box.


First, record the front and back position of the control to be moved

Statement

    /** @brief List control moves up the position rectangle */    qrect listmatchresultuprt;    /** @brief List control moves down the position rectangle */    qrect LISTMATCHRESULTDNRT;

Defined

void Featurematchqtdlgi::initadvancedcontrolrt () {    listmatchresultuprt = ui->labelinitsamplepro-> Geometry ();    LISTMATCHRESULTDNRT = Ui->listmatchresult->geometry ();    Listmatchresultuprt.setwidth (Listmatchresultdnrt.width ());    Listmatchresultuprt.setheight (Listmatchresultdnrt.height ());}
Moving hidden and moving display functions

Move hidden

void Featurematchqtdlgi::hideadvancedcontrol () {    ui->labelinitsamplepro->setvisible (false);    Ui->labelcontrastthreshold->setvisible (false);    Ui->labelmatchthreshold->setvisible (false);    Ui->labelmaxmatchnumber->setvisible (false);    Ui->combinitsamppro->setvisible (false);    Ui->spincontrastthreshold->setvisible (false);    Ui->spinmatchthreshold->setvisible (false);    Ui->spinmaxmatchnumber->setvisible (false);    Ui->listmatchresult->setgeometry (LISTMATCHRESULTUPRT);}

Mobile Display

void Featurematchqtdlgi::showadvancedcontrol () {    ui->listmatchresult->setgeometry (ListMatchResultDnRT) ;    Ui->labelinitsamplepro->setvisible (true);    Ui->labelcontrastthreshold->setvisible (true);    Ui->labelmatchthreshold->setvisible (true);    Ui->labelmaxmatchnumber->setvisible (true);    Ui->combinitsamppro->setvisible (true);    Ui->spincontrastthreshold->setvisible (true);    Ui->spinmatchthreshold->setvisible (true);    Ui->spinmaxmatchnumber->setvisible (TRUE);}

Three, button slot function

        static bool isopenadvancedsetting = FALSE;        if (isopenadvancedsetting)        {            isopenadvancedsetting = false;            Hideadvancedcontrol ();        }        else        {            isopenadvancedsetting = true;            Showadvancedcontrol ();        }

Program Run Result:

Hidden display and movement of QT5 controls

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.