wahjam/wahjam — pull request #55 by teamikl (2012-06-12 02:49:50+00:00)
Title: Default layout

This request has two topics.

* set margins and spacing for layout.
* add stylesheet support for MetronomeBar. (not completely)

I did not adjust margin/spacing values, those const value hard coding in source is not good.
I was thinking to use stylesheet for that. but that was not possible for layout. report in this post below.

----
I noticed when I run qtclient with -styte argument,
some of widgets may have different size. (e.g. ComboBox in ConnectionDialog did not expand width)

----
QLayout did not inherit QWidget

Unfortunately, stylesheet can not set margin/spacing of Layout.

stylesheet can set **Designable** QObject property.
but QLayout::spacing property was not marked as designable.

note two quick ideas (did not try yet)

* QScript may be possible to change the spacing property.
* custom QObject with designable properties and pass that to layout.

I feel stylesheet is right place to set those margin/spacing.
but set the designable property has prefix, that would be like qtproperty-spacing: 0px;

users who want to make custom layout/style would meet this issue.

----
I was trying to set default stylesheet. that was not good idea.

when I set app.setStyleSheet(defaultStyleSheet) then -stylesheet argument does not work.
because QApplication constructor handle that -stylesheet argument.
app.setStyleSheet always override user given -stylesheet. maybe same to setStyle and -style option.

I'd like to keep blank the default stylesheet, that make user can use -stylesheet option.

----
Demo: apply stylesheet for MetronomeBar

```css
// style.qss
MetronomeBar {
background-color: none;
color: red;
}
```

```sh
> ./qtclient -stylesheet ./style.qss
```

not completely ... I did not test so much cases, and I met some does not work as expected.

e.g. margin: 10px; will break the metronome shape.
(small border but click rect area size did not follow the border size)

----

more about -style options
http://qt-project.org/doc/qt-4.8/qapplication.html#QApplication
http://qt-project.org/doc/qt-4.8/qapplication.html#setStyle-2

The Style Sheet Syntax - Setting QObject properties
http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html#setting-qobject-properties

Stylesheet controls for QLayout objects
https://bugreports.qt-project.org/browse/QTBUG-22862

Stylesheet reference and examples
http://qt-project.org/doc/qt-4.8/style-reference.html
http://qt-project.org/doc/qt-4.8/stylesheet-examples.html