简体   繁体   English

QT:如何将IconTool框放置在窗口的右侧

[英]QT: How to position a IconTool box on the right side of a window

QT 4.8, C++ QT 4.8,C ++

I have a few dock-able icon tool box widgets in my window. 我的窗口中有一些可停靠的图标工具框小部件。

They are all displayed horizontally, on the first line. 它们全部水平显示在第一行。 I would like to anchor (by default) one of the tool boxes to the right corner of the window , as displayed in the pic. 我想(默认情况下)将工具箱之一锚定到窗口的右上角 ,如图所示。

Note that the the tool bar needs to keep anchored as I resize the window. 请注意,在调整窗口大小时,工具栏需要保持锚定状态。 Also, since the tool bars are dock-able, then can be moved or re-ordered by the user. 而且,由于工具栏是可停靠的,因此可以由用户移动或重新排序。

This is an example I made (with paint, with Visual Studio windows) that exemplify the issue: 这是我制作的一个示例(使用画图,使用Visual Studio窗口)来说明问题:

窗口右上方的工具箱示例

You could probably create a QWidget and use it as a spacer in the left tool bar. 您可能会创建一个QWidget并将其用作左侧工具栏中的间隔符。 Place the spacer after the undo/redo buttons and set the size policy and it's minimum width (or alternatively subclass and re-implement it's size hint) to get a desired behaviour: 在撤消/重做按钮后放置间隔符,并设置大小策略及其最小宽度(或者子类并重新实现它的大小提示)以获得所需的行为:

QWidget spacer;
spacer.setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
spacer.setMinimumWidth(200);
fileToolBar->addWidget(&spacer);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM