Show on the text in qml one by one

hello.
How to get the records database of golang and show on the text in qml one by one .
it is my table.
is iterative records.

my code:
golang:

package main
import (
    "fmt"
    "os"
    "github.com/go-qml/qml"
    "database/sql"
    _ "github.com/mattn/go-sqlite3"	
)

func main() {
    if err := qml.Run(run); err != nil {
        fmt.Fprintf(os.Stderr, "error: %v\n", err)
        os.Exit(1)
    }
}

func run() error {
	////
    db, err := sql.Open("sqlite3", "./foo.db")
    rows, err := db.Query("select * from foo")
////
    engine := qml.NewEngine()
    engine.On("quit", func() { os.Exit(0) })

    component, err := engine.LoadFile("hello.qml")
    if err != nil {
        return err
    }
	  
	     for rows.Next() {
		var id int
	     var namee string
        var familyy string
        rows.Scan(&id, &namee, &familyy)
		// println(id)
        // println(namee)
		// println(familyy)
		context := engine.Context()
    context.SetVar("ctrl", &Control{Name:namee,Family:familyy})
	//println(familyy)
	}
	defer rows.Close()
    window := component.CreateWindow(nil)
    window.Show()
    window.Wait()
    return nil
}

type Control struct {
    Name    string
    Family    string 
}

qml:

 Text {
	text: ctrl.name
	color:"#000000";
 }

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.