我是Qt的新手,我正在尝试创建一个停靠在窗口右侧的DockWidget。我为底座设置了最大和最小宽度(如下面的代码所示)。如果使用Qt::LeftDockWidgetArea
添加停靠窗口小部件,但是当它与Qt::RightDockWidgetArea
一起添加时,此功能可用,则会将停靠栏“填充”到窗口的中心,如下所示:
我可能没有以正确的方式调整扩展坞的大小。以下是此窗口的代码:
int main(int argv, char** args)
{
QApplication app(argv, args);
QMainWindow window;
QDesktopWidget* desktop = QApplication::desktop();
//Docks
QDockWidget* propertyDock = new QDockWidget("",&window);
QWidget* propertyDockContents = new QWidget;
//This sets the window in the center of the screen.
int wWidth = 800; int wHeight = 600;
window.setGeometry(QRect( (desktop->width()-wWidth)/2 , (desktop->height()-wHeight)/2 ,wWidth,wHeight));
propertyDock->setAllowedAreas(Qt::RightDockWidgetArea);
propertyDockContents->setMaximumWidth(200);
propertyDockContents->setMinimumWidth(20);
propertyDock->setWidget(propertyDockContents);
window.addDockWidget(Qt::RightDockWidgetArea,propertyDock);
window.show();
return app.exec();
}
有没有“正确”的方法来做到这一点?
答案 0 :(得分:3)
如文件中所述:
注意:不支持创建没有中央窗口小部件的主窗口。即使它只是占位符,您也必须拥有一个中央窗口小部件。
答案 1 :(得分:0)
是的!如果没有中央小部件,则无法创建主窗口,但是可以将中央小部件的高度设置为零。 MainWindow.cpp
href="./view-all.php?tablename=<?php echo $row[0];?>"