diff --git a/.gitignore b/.gitignore index 424691d7..84afad02 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/examples/lcdclock6/lcdclock6.png b/examples/lcdclock6/lcdclock6.png new file mode 100644 index 00000000..7f53e00d Binary files /dev/null and b/examples/lcdclock6/lcdclock6.png differ diff --git a/examples/lcdclock6/main.go b/examples/lcdclock6/main.go new file mode 100644 index 00000000..bf373650 --- /dev/null +++ b/examples/lcdclock6/main.go @@ -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() +}