mirror of
https://github.com/mappu/miqt.git
synced 2024-12-22 00:48:38 +00:00
qnetwork: add example
This commit is contained in:
parent
d716265ca1
commit
62aa3fb25e
1
.gitignore
vendored
1
.gitignore
vendored
@ -26,6 +26,7 @@ examples/mdoutliner/mdoutliner
|
||||
examples/windowsmanifest/windowsmanifest
|
||||
examples/uidesigner/uidesigner
|
||||
examples/libraries/extras-scintillaedit/extras-scintillaedit
|
||||
examples/libraries/qt-network/qt-network
|
||||
examples/libraries/qt-printsupport/qt-printsupport
|
||||
examples/libraries/restricted-extras-qscintilla/restricted-extras-qscintilla
|
||||
|
||||
|
38
examples/libraries/qt-network/main.go
Normal file
38
examples/libraries/qt-network/main.go
Normal file
@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/mappu/miqt/qt"
|
||||
"github.com/mappu/miqt/qt/network"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
qt.NewQApplication(os.Args)
|
||||
|
||||
log.Printf("Looking up DNS info, please wait...")
|
||||
|
||||
dns := network.NewQDnsLookup2(network.QDnsLookup__A, "google.com")
|
||||
dns.OnFinished(func() {
|
||||
dns.DeleteLater()
|
||||
|
||||
if dns.Error() != network.QDnsLookup__NoError {
|
||||
log.Printf("An error occurred: %v", dns.ErrorString())
|
||||
return
|
||||
}
|
||||
|
||||
results := dns.HostAddressRecords() // CanonicalNameRecords, TextRecords, ServiceRecords, ...
|
||||
log.Printf("Found %d result(s).", len(results))
|
||||
|
||||
for _, record := range results {
|
||||
log.Printf("- %s", record.Value().ToString())
|
||||
}
|
||||
|
||||
qt.QCoreApplication_Exit()
|
||||
})
|
||||
dns.Lookup()
|
||||
|
||||
qt.QApplication_Exec()
|
||||
}
|
Loading…
Reference in New Issue
Block a user