个horizontalLayout中的两个QTextEdit控件按2:3的比例扩大或缩小时其实很简单.
void QBoxLayout::setStretch(int index, int stretch)
Sets the stretch factor at position index. to stretch.
This function was introduced in Qt 4.5.
See also stretch().
这是Help文件的内容。整理一下,就是一个Layout中,设置每个对象的相对比例。例如一个QHBoxLayout中放置两个Widget的时候,需要1比1的扩大或缩小,应这样设置:
m_pContext = new QHBoxLayout;
m_pContext->addLayout(m_pVLeft);
m_pContext->addLayout(m_pVRight);
m_pContext->setStretch(0,1);
m_pContext->setStretch(1,1);
如果是1比3的扩大或缩小:
m_pContext = new QHBoxLayout;
m_pContext->addLayout(m_pVLeft);
m_pContext->addLayout(m_pVRight);
m_pContext->setStretch(0,1);
m_pContext->setStretch(1,3);