Qt designer: How to add widget to a layout in the designer when the layout appears infinitely thin?

旧城冷巷雨未停 提交于 2019-12-03 14:28:01

问题


I am using Qt Designer, and I would like to move a couple of top-level widgets into a horizontal layout.

I have dragged a "Horizontal Layout" object into the form. I am now attempting to drag the desired widgets into the layout.

Unfortunately, the new Horizontal Layout widget is infinitely thin:

... and I cannot drag my "Import Progress" label widget or my progress bar widget into the new horizontal layout widget.

Note that when I attempt to drag the desired widgets over the new horizontal layout widget, Qt Designer does not do anything useful for me in terms of expanding the drop region to make the horizontal widget available as a drop target. So I'm stuck.

How do I add widgets to an infinitely-thin layout widget in Qt Designer?


回答1:


Select the layout, and then drop the widget onto the corresponding selected item in the Object Inspector pane. If you find it tricky to select the layout on the actual form, you can also select it via the Object Inspector pane.




回答2:


One way (that I usually do as a workaround for not having to show the structure panel) is to select the layout, setting the top or bottom margins to any value (10, whatever) and then dragging the component into the layout. Yeah, that is just for the pure pleasure of dropping the component in the layout, i know, but is a way.




回答3:


My small trick:

  • Select layout
  • Change temporary "layoutTopMargin"
  • Drop into layout required widgets
  • Restore layoutTopMargin to default 0


来源:https://stackoverflow.com/questions/22597084/qt-designer-how-to-add-widget-to-a-layout-in-the-designer-when-the-layout-appea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!