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