我有一个 QTDesigner 对话框,其中 QDockWidget 作为主要小部件。当我将它停靠到主窗口并显示对话框时,它会自动自动隐藏,但允许我使用鼠标显示/隐藏它。我想默认保持可见。如果我使用鼠标将其调整为大尺寸,大约是屏幕尺寸的 2/3,然后关闭对话框并稍后显示它,即使我关闭最后一个大尺寸的应用程序,它也会按我的意愿工作。
这些是我的课:
/** created automatically by QT compiler */
class Ui_OfsIndSelAttribBase
{
public:
QWidget *dockWidgetContents;
QVBoxLayout *verticalLayout_10;
QGroupBox *_p_gB_Filters;
QVBoxLayout *verticalLayout_9;
QVBoxLayout *verticalLayout_4;
....
void setupUi(QDockWidget *dockWidget)
{
if (dockWidget->objectName().isEmpty())
dockWidget->setObjectName(QString::fromUtf8("dockWidget"));
dockWidget->resize(352, 789);
dockWidget->setFloating(false);
dockWidgetContents = new QWidget();
dockWidgetContents->setObjectName(QString::fromUtf8("dockWidgetContents"));
...
}
};
我的对话类树:
class FCSDockableInputDataQt: public QDockWidget
{
Q_OBJECT
public:
/** GetMainWindow() returns a valid QT main window */
FCSDockableInputDataQt(Qt::DockWidgetArea do = Qt::BottomDockWidgetArea,
Qt::WFlags f=0) :
QDockWidget("MyDialog", GetMainWindow(), f)
{
....
}
};
/** this is my dialog management class */
class OfsIndSelAttribQt : public FCSDockableInputDataQt,
public Ui::OfsIndSelAttribBase
{
Q_OBJECT
OfsIndSelAttribQt() :
FCSDockableInputDataQt(Qt::RightDockWidgetArea)
{
setupUi(this);
setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
setFloating(false);
....
}
};