Skip to content

mappu/autoconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

autoconfig

Image Go Reference

Autoconfig allows you to edit any Go struct with a Qt interface based on MIQT.

type Foo struct {                []----------------------[]
    Name string                  |  Name:  [___________]  |
}                                |                [Save]  |
                                 []----------------------[]

Usage

Creating a dialog:

// 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:

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
      • A custom QSpinBox is implemented for large bit-width types
    • float
    • complex
    • pointer (optional)
      • struct tags on the pointer are passed in to the child renderer
      • supports Resetter interface to allow resetting to default values
    • 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-16 v0.6.0

  • Pointers: Allow resetting any pointer type that implements Resetter
  • Allow scrolling tall dialog boxes
  • Render "xxDir" string struct fields as if they were ExistingDirectory
  • Render "xxPass", "xxPassword" string struct fields as if they were Password
  • Fix overflow for int64 and uint32/64 by implementing custom QSpinBox

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

About

Edit any Go struct with a Qt interface

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages