简体   繁体   中英

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

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:

窗口右上方的工具箱示例

You could probably create a QWidget and use it as a spacer in the left tool bar. 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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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