Merge pull request #224 from rcalixte/add_lcdclock6

lcdclock6: Add Qt 6 lcdclock example
This commit is contained in:
mappu 2025-05-22 17:43:18 +12:00 committed by GitHub
commit 5ac6083a3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 54 additions and 0 deletions

1
.gitignore vendored
View File

@ -16,6 +16,7 @@ examples/goroutine6/goroutine6
examples/helloqml6/helloqml6
examples/helloworld/helloworld
examples/helloworld6/helloworld6
examples/lcdclock6/lcdclock6
examples/mdoutliner/mdoutliner
examples/mdoutliner6/mdoutliner6
examples/windowsmanifest/windowsmanifest

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1,53 @@
package main
import (
"os"
"strings"
qt "github.com/mappu/miqt/qt6"
)
func main() {
qt.NewQApplication(os.Args)
widget := qt.NewQWidget2()
defer widget.Delete()
widget.SetWindowTitle("Qt 6 LCD Clock Example")
widget.Resize(360, 240)
hbox := qt.NewQHBoxLayout(widget)
lcd := qt.NewQLCDNumber(widget)
lcd.SetFont(qt.NewQFont6("DejaVu Serif", 14))
lcd.SetStyleSheet("background-color: #729fcf; color: white;")
time := qt.QTime_CurrentTime()
defer time.Delete()
text := time.ToStringWithFormat("hh:mm")
if (time.Second() % 2) == 0 {
text = strings.Replace(text, ":", " ", -1)
}
lcd.Display(text)
hbox.AddWidget(lcd.QFrame.QWidget)
timer := qt.NewQTimer2(widget.QObject)
timer.Start(1000)
timer.OnTimerEvent(func(super func(param1 *qt.QTimerEvent), param1 *qt.QTimerEvent) {
time := qt.QTime_CurrentTime()
defer time.Delete()
text := time.ToStringWithFormat("hh:mm")
if (time.Second() % 2) == 0 {
text = strings.Replace(text, ":", " ", -1)
}
lcd.Display(text)
})
widget.Show()
qt.QApplication_Exec()
}