Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use QThreads with the binding #567

Closed
MTRNord opened this issue Mar 10, 2018 · 3 comments
Closed

How to use QThreads with the binding #567

MTRNord opened this issue Mar 10, 2018 · 3 comments

Comments

@MTRNord
Copy link

MTRNord commented Mar 10, 2018

I already asked in the slack before but didn't get a awnser. Is there any example on how to correctly use QThreads in this go binding? (goroutines are in my code not useful as it still is the gui thread)

@therecipe
Copy link
Owner

Hey

You should be able to use go routines as well, but here is an example how to use QThreads:

package main

import (
	"os"
	"time"

	"github.com/therecipe/qt/core"
)

func main() {
	core.NewQCoreApplication(len(os.Args), os.Args)

	t := core.NewQThread(nil)
	t.ConnectRun(func() {
		time.Sleep(4 * time.Second)
		println("thread:", core.QThread_CurrentThread().Pointer())
	})
	t.Start()

	go func() {
		time.Sleep(5 * time.Second)
		println("go routine:", core.QThread_CurrentThread().Pointer())
		os.Exit(0)
	}()

	println("main:", core.QThread_CurrentThread().Pointer())

	core.QCoreApplication_Exec()
}

@therecipe
Copy link
Owner

Okay, seems to be solved.
Will close this now, please re-open or open a new issue if you need to.

@MTRNord
Copy link
Author

MTRNord commented Mar 26, 2018

Sorry did forget to close it :) yes it is solved 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants