当使用QSplitter时,如果是多个QSPlitter嵌套使用(如下图)
就很容易出现错误。通常是“内存不能为read” (如下图)
代码如下:(错误的用法)
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QSplitter>
#include <QTextEdit>
#include <QTableWidget>
#include <QTreeWidget>
#include <QSettings>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QTextEdit *editor1 = new QTextEdit;
QTableWidget *table = new QTableWidget;
QTreeWidget *tree = new QTreeWidget;
//子splitter
QSplitter vSplitter(Qt::Vertical);
vSplitter.addWidget(table);
vSplitter.addWidget(editor1);
//父splitter
QSplitter hSplitter(Qt::Horizontal);