mappu / miqt

MIT-licensed Qt bindings for Go
MIT License
272 stars 10 forks source link

NewIcon4(filename) silently fails for .SVG files #62

Open mark-summerfield opened 1 week ago

mark-summerfield commented 1 week ago

I have just started trying out miQt using Qt 6.4.2 on Debian. I tried adding an application icon. When I use go-up.png it works fine; but when I use go-up.svg no icon appears.

package main

import (
    "fmt"
    "os"

    qt "github.com/mappu/miqt/qt6"
)

func main() {
    var counter int
    qt.NewQApplication(os.Args)

    window := qt.NewQWidget2()
    icon := qt.NewQIcon4("go-up.png")
    window.SetWindowIcon(icon)
    helloButton := qt.NewQPushButton3("Hello world!")
    aboutButton := qt.NewQPushButton3("About Qt")

    helloButton.OnPressed(func() {
        counter++
        helloButton.SetText(fmt.Sprintf(
            "You have clicked the button %d time(s)", counter))
    })
    aboutButton.OnPressed(func() { qt.QApplication_AboutQt() })

    box := qt.NewQHBoxLayout(window)
    box.AddWidget(helloButton.QWidget)
    box.AddWidget(aboutButton.QWidget)

    window.Show()
    qt.QApplication_Exec()
}

go-up go-up

mappu commented 1 week ago

These icons are loaded using Qt Image Format plugins. Qt always supports an imageformat for PNG, but SVG support requires loading the SVG plugin.

I think this only requires linking with QtSvg in LDFLAGS. It may also require the imageformats/svg plugin to be present at runtime.

I'll work on an example solution.

mark-summerfield commented 1 week ago

Thank you.

5k3105 commented 21 hours ago

the actual recipe . . . ? wild guess