mirror of
https://github.com/mappu/miqt.git
synced 2025-05-23 19:40:26 +00:00
lcdclock6: Add Qt 6 lcdclock example
This commit is contained in:
parent
8aedac421d
commit
fc7a764931
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
|
||||
|
BIN
examples/lcdclock6/lcdclock6.png
Normal file
BIN
examples/lcdclock6/lcdclock6.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.1 KiB |
53
examples/lcdclock6/main.go
Normal file
53
examples/lcdclock6/main.go
Normal 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()
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user