restraining a KComboBox widget's width in an expandable dialog

René J.V. Bertin rjvbertin at
Thu Nov 17 17:30:17 GMT 2016


I'm working on a more complete CMake project configuration dialog that offers the same configuration fields as the dialog used during the initial creation of such a project.
There's a layout issue concerning one of the widgets for which I'd appreciate a some pointers allowing me to address it properly. I'm hoping to find some people on the KDevelop users ML who are more experienced than I with getting KDE widgets look right :)

It's a KComboBox that has a history feature and can hold entries that get quite long (the extra arguments list; in my own use). Because the project configuration dialog is expandable (to accommodate the full build dir path) it gets resized so that the KComboBox can show the longest entry in full.

I stumbled upon a workaround (basically by printing out dynamic_cast<QComboBox*>(extraArguments)->minimumSizeHint()) which as a probable side-effect gives the widget the same width as the other widgets in the advanced box.

The widget gets the intended size when I don't add the history items. So I think that a proper fix would determine the KComboBox width before it is filled with the argument history, and set that as the preferred width. But apparently that width isn't known yet in the ctor.


----------  Forwarded Message  ----------

This is an automatically generated e-mail. To reply, visit:

There is something wonky with the extra arguments widget width for which I've only found a workaround I don't really understand. The widget hlayout is set to expanding in the ui.rc, but this causes the whole `CMakePreferences` dialog to expand to accomodate the longest string in the argument history. I think that's because the dialog itself is configured to allow expansion whereas the `CMakeBuildDirChooser` dialog has a fixed size. I presume that doing a dynamic_cast from `KComboBox` to `QComboBox` has a side-effect which causes the widget to adopt the desired width and not become a lot wider.

More information about the KDevelop mailing list