https://github.com/mappu/autoconfig
Edit any Go struct with a Qt interface
https://github.com/mappu/autoconfig
Last synced: 6 months ago
JSON representation
Edit any Go struct with a Qt interface
- Host: GitHub
- URL: https://github.com/mappu/autoconfig
- Owner: mappu
- License: mit
- Created: 2025-11-15T01:52:31.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-12-03T06:27:32.000Z (7 months ago)
- Last Synced: 2025-12-06T07:37:05.506Z (7 months ago)
- Language: Go
- Size: 79.1 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# autoconfig

[](https://pkg.go.dev/github.com/mappu/autoconfig)
Autoconfig allows you to edit any Go struct with a Qt interface [based on MIQT](https://github.com/mappu/miqt).
```
type Foo struct { []----------------------[]
Name string | Name: [___________] |
} | [Save] |
[]----------------------[]
```
## Usage
Creating a dialog:
```golang
// Passed in struct should be a pointer value
var foo MyStruct
autoconfig.OpenDialog(&foo, nil, "Dialog title", func() {
// The value of 'foo' has been updated
})
```
Embedding into an existing layout:
```golang
var foo MyStruct
saveCallback := autoconfig.MakeConfigArea(&foo, qt6.QFormLayout)
// To save changes from the GUI into the struct, call the saveCallback() function.
// However, warning that nested fields may be mutated automatically without calling.
```
Only public fields are supported. This is a limitation of the standard library `reflect` package.
## Supported types
- All Go primitive types
- string
- bool
- int
- including uintptr, uint, and fixed-width versions
- float
- complex
- pointer (optional)
- struct tags on the pointer are passed in to the child renderer
- slice
- []byte
- supports MIME content detection, multiline text editor, and importing and exporting file content
- fixed-size array
- map
- struct
- child structs by value, and embedded structs, are rendered inline
- struct tags on the slice are passed in to each child renderer
- empty struct
- Standard library types
- time.Time
- Custom types
- AddressPort
- EnumList
- ExistingDirectory
- ExistingFile
- Header
- MultilineString
- Password
- Any custom type that implements the `Renderer` interface
- Custom layouts
- OneOf
- TabGroup
## Customization
Add struct tags to individual fields to customize the rendering:
|Tag |Behaviour
|---------|------
|`ylabel` |Override label. If not present, the default label is the struct field's name with underscores replaced by spaces.
|`yenum` |For "EnumList"; list of dropdown options, separated by double-semicolon (`;;`)
|`yfilter`|For "ExistingFile"; filter to apply in popup dialog
|`yicon` |For "OneOf" and "TabGroup"; icon (either from theme, or with `:/` prefix for resource icon)
|`yprefix`|For int, uint, float types; text to display as a prefix (e.g. "at least")
|`ysuffix`|For int, uint, float types; text to display as a suffix (e.g. "%" or "bytes")
Implement these interfaces to customize the rendering:
|Interface |Behaviour
|----------------|---------
|`Resetter` |May be used with pointer receiver to reset your type to default values, if autoconfig constructed a new version of your type (used by OneOf, pointer, and slice)
|`Renderer` |Add a fully custom Qt widget. Use with either value or pointer receiver.
|`fmt.Stringer` |May be used to format some types for display
## Changelog
2026-01-04 v0.5.0
- Support map
- Support fixed-size arrays
- Support `[]byte` with special handling, including MIME content detection and file import/export
- Support `complex64` and `complex128`
- Add `TabGroup`
- Add `yprefix` and `ysuffix` support for int, uint, and float types
- Labels: Hide standalone `:` if a blank label was used
- Labels: Hide duplicate labels if text was already shown in dialog/tab/dropdown
- Fix label formatting for strings
- Show `""` as the label formatting for the empty string
2025-12-03 v0.4.1
- Reduce flicker on Windows by enforcing Qt parent relationship during creation
2025-12-03 v0.4.0
- Reduce flicker on Windows by setting Qt UpdatesEnabled false during struct calculation
- OneOf: support Reset()
- Labels: Support String() on ExistingFile and ExistingDirectory
- Labels: Support labels on pointer types, with parenthesis
- Labels: Support labels on structs using OneOf
- Labels: Automatically convert CamelCase struct names to separated words
- Struct tags are now passed through to slice and pointer children (e.g. allowing `yfilter` on `*ExistingFile`)
- Use accurate type comparison for `time.Time` and `OneOf`, in case of naming conflict in other packages
2025-11-26 v0.3.0
- BREAKING: Rename `InitDefaulter` to `Resetter`, rename `Autoconfiger` to `Renderer`
- Add `OneOf`
- Renderer interface now supports being implemented on either value or pointer receiver
- `AddressPort` now renders a string description when used in a slice
2025-11-17 v0.2.0
- Support arbitrary pointers, slices, int, uintptr, float, `time.Time`
- Add `Header`
- Skip over unsupported types (func, interface, `unsafe.Pointer`)
- Fix cosmetic inconsistency when editing types
2025-11-15 v0.1.0
- Initial public release