Qt6 Examples #223
-
Hi all, I'm working with the mappu/miqt/qt6 bindings and I’m trying to implement a splash screen that shows for 3 seconds before switching to the main window, ideally using QTimer. Unfortunately, I haven't found any examples that use QTimer, and the current demos are quite minimal. Does anyone have a more complete example using QTimer, or even more advanced miqt apps in general that go beyond basic button clicks and layouts? Thanks in advance! Pol Guarch |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hello, I was able to piece together this example that shows the splash screen for three seconds before showing the next QWidget which is the QPushButton in this case but it could easily be a QMainWindow or whatever you want. You can customize the splash screen image further by modifying the QPixmap object. I modified the package main
import (
"fmt"
"os"
qt "github.com/mappu/miqt/qt6"
)
func main() {
qt.NewQApplication(os.Args)
pixmap := qt.NewQPixmap4("logo.png")
defer pixmap.Delete()
splash := qt.NewQSplashScreen4(pixmap, qt.WindowStaysOnTopHint)
defer splash.Delete()
// disable closing the splash screen with a click
// comment the next two lines to re-enable
splash.OnMousePressEvent(func(super func(param1 *qt.QMouseEvent), param1 *qt.QMouseEvent) {
})
btn := qt.NewQPushButton3("Hello world!")
btn.SetFixedWidth(320)
var counter int = 0
btn.OnPressed(func() {
counter++
btn.SetText(fmt.Sprintf("You have clicked the button %d time(s)", counter))
})
splash.Show()
timer := qt.NewQTimer()
defer timer.Delete()
timer.Start(3000)
timer.OnTimeout(func() {
splash.Close()
btn.Show()
timer.Stop()
})
qt.QApplication_Exec()
fmt.Println("OK!")
} I converted the I was able to piece this together using the documentation from: There are some QTimer functions that are currently not projected that pose some challenges but these can hopefully be sorted out over time. Until then, I think there are workarounds available for most use cases. I don't know if this rises to needing a dedicated example but hopefully this helps if someone ends up searching for it or needing it in the future. (Updated with the |
Beta Was this translation helpful? Give feedback.
Hello, I was able to piece together this example that shows the splash screen for three seconds before showing the next QWidget which is the QPushButton in this case but it could easily be a QMainWindow or whatever you want. You can customize the splash screen image further by modifying the QPixmap object. I modified the
helloworld6
example here: