Split windows are often used in applications. They can flexibly distribute window la S, which are often used in window design similar to file resource manager. Then, with such an idea, a simple implementation is realized.
// Main. CPP # include <qapplication> # include <qsplitter> # include <qtextedit> # include <qtextcodec> int main (INT argc, char * argv []) {qtextcodec :: setcodecfortr (qtextcodec: codecforlocale (); qapplication app (argc, argv); // create a main split window and set the direction to qsplitter * mainsplitter = new qsplitter (QT :: horizontal, 0); // create a qtextedit control and set its parent control to mainsplitter qtextedit * leftedit = new qtextedit (qobject: TR ("Left window"), mainsplitter ); // set the align mode of the text in the qtextedit control to center the display of leftedit-> setalignment (QT: aligncenter ); // create a right split window and set its parent control to mainsplitter. Set the direction to Vertical Split Window. Finally, it is split into two upper and lower windows: qsplitter * rightsplitter = new qsplitter (QT: vertical, mainsplitter ); // set whether the bars in the split window are updated in real time when being dragged. If the value is set to true, the bars are updated in real time. If the value is false, only one gray line is displayed. // After the bars are dragged in place and the mouse is clicked display the divider rightsplitter-> setopaqueresize (false ); // start to split it into two upper and lower windows qtextedit * upedit = new qtextedit (qobject: TR ("upper window"), rightsplitter); upedit-> setalignment (QT :: aligncenter); qtextedit * bottomedit = new qtextedit (qobject: TR ("bottom window"), rightsplitter); bottomedit-> setalignment (QT: aligncenter ); // set the number of the control set by the first parameter of the Scalable Control, the control serial number starts from 0 in the order of insertion. // The second parameter is greater than 0, indicating that the control is a scaling control. In this example, set the right split window to the Scalable Control mainsplitter-> setstretchfactor (1, 1); mainsplitter-> setwindowtitle (qobject: TR ("Split Window"); mainsplitter-> show (); Return app.exe C ();}