如何在 Qt Creator src 中获取和移动 EditorManager 的父级 window?

How to get and move the parent window of an EditorManager in Qt Creator src?

我打开了 1 个 Qt Creator 实例,其中有 2 个浮动 windows(在新 Window 中打开)。这给了我总共 3 "editor windows"。每个 "editor window" 有 3 个水平分割,给我 +-9 个打开的文档。我把它分布在 3 个显示器上,就像这样

我通常会休眠我的工作站,但如果我遇到崩溃并不得不重新启动,或者我在另一台机器上打开项目,我会丢失浮动的 windows 和拆分的文档以及滚动的位置在那些文档中,我必须手动重新开始重新排列所有内容。 我希望在项目加载时保存并调用此浮动获胜位置和编辑器视图拆分数据

为了解决这个问题,我一直在从源代码构建 Qt Creator。我的第一个任务是移动初始(或浮动)window。我已经找到了一些东西,但是 我找不到 EditorManager 的 "parent widget",也就是上面提到的 "editor manager"。因此,只有编辑经理搬家,这显然是我不希望的。 如何访问和移动初始父级 window 和浮动 windows?

//editormanager.cpp

void EditorManagerPrivate::restoreFloatingWindows()
{
    for (int i = 0; i < d->m_editorAreas.size(); ++i)
    {
       d->m_editorAreas[i]->move(100, 100); // don't want to move this
       d->m_editorAreas[i]->parentWidget()->move(100, 100); //no effect

        qDebug() << "pos" << d->m_editorAreas[i]->pos();
        qDebug() << "pos parentWidget" << d->m_editorAreas[i]->parentWidget()->pos();
    }
}

从 Qt 5 开始,所有 QWidgets 都有一个指向包含 window 的指针。

http://doc.qt.io/qt-5/qwidget.html#window

就存储和调用几何和状态而言,这些方法非常有用:

http://doc.qt.io/qt-5/qwidget.html#saveGeometry

http://doc.qt.io/qt-5/qwidget.html#restoreGeometry

http://doc.qt.io/qt-5/qmainwindow.html#saveState

http://doc.qt.io/qt-5/qmainwindow.html#restoreState

使用QSettings时,启动一个数组,然后为每个window推送这些值。或者在加载项目时,提取每个值并使用适当的 setter.

希望对您有所帮助。