Qt Spliiter类

xiaoxiao2021-02-27  534

#include "qstackWidget.h" #include <QtWidgets/QApplication> #include <QSplitter> #include <QTextEdit> #include <QTextCodec> int main(int argc, char *argv[]) { QApplication a(argc, argv); // qstackWidget w; // w.show(); QFont font("Times", 18); a.setFont(font); //主分隔窗口 QSplitter *pSplitterMain = new QSplitter(Qt::Horizontal); //建立文本,显示在主分隔窗口 QTextEdit *textLeft = new QTextEdit("Left Widget", pSplitterMain); textLeft->setAlignment(Qt::AlignHCenter);//设置文本的对齐方式是中心对称 //右部分分隔窗口 QSplitter *pSplitterRight = new QSplitter(Qt::Horizontal, pSplitterMain);//右分隔窗口的父窗口是主分隔窗口 pSplitterRight->setOpaqueResize(true);//显示实时更新 QTextEdit *textUp = new QTextEdit("Top Widget", pSplitterRight);// textUp->setAlignment(Qt::AlignCenter); QTextEdit *textBottom = new QTextEdit("bottom Widget", pSplitterRight); textBottom->setAlignment(Qt::AlignCenter); pSplitterMain->setStretchFactor(0,1); pSplitterMain->setWindowTitle("Splitter"); pSplitterMain->show(); return a.exec(); }
转载请注明原文地址: https://www.6miu.com/read-213.html

最新回复(0)