Giter Site home page Giter Site logo

Resource files about qt HOT 10 CLOSED

therecipe avatar therecipe commented on August 28, 2024
Resource files

from qt.

Comments (10)

gen2brain avatar gen2brain commented on August 28, 2024

Ok, I figured out, renamed ui/ dir to qml/ and changed paths inside .ui files.
Is there a way to generate just qrc.go without qtdeploy? I would like to use just go build without qtdeploy with my static Qt build in chroot.

Still, something is strange when you try to load pixmap from byte/string, or I am doing something wrong there?

from qt.

therecipe avatar therecipe commented on August 28, 2024

Hey

Currently the qrc.* files are generated on the fly by qtdeploy.

The qrc.go file just contains a few LDFLAGS and can be reused, if you can obtain a copy while executing qtdeploy.
The qrc.qrc and qrc.cpp files are created with Qt's rcc tool.

You can also take a look here, to see how its handled in qtdeploy.
It's probably simpler if you use rcc directly, instead of me exposing it through qtdeploy or something?

And yes, the QPixmap.LoadFromData functions are currently broken. (As well as a few other functions which use QByteArray)
I made a mistake by mapping QByteArray to Go's string instead of []byte.
But I will fix this in an upcoming release.

For now you can only load it from the filesystem or if you use rcc you can also load it with qrc:///

from qt.

gen2brain avatar gen2brain commented on August 28, 2024

Hi,

Ok, I can just use rcc directly, I thought qtdeploy does more.

I am having issue currently with loading html file from resources. Icons in .ui files work but something like this loads file randomly (e.g. every 5th time)

    var res string
file := core.NewQFile2(":/qml/assets/view.html")
file.Open(core.QIODevice__ReadOnly)
if file.IsOpen() {
    res = file.ReadAll()
}
file.Close()

Hopefully, this will be fixed in upcoming release. Thanks!

from qt.

therecipe avatar therecipe commented on August 28, 2024

Hey

Beside the qrc/rcc support, qtdeploy handles also a few other things:

  • Moc support to create your own subclasses with signals/slots
  • Dynamically rebuilds the minimal version of the binding to make the executable smaller
  • Handles the packaging (macdeploy, windeploy, ...) of the application for the different systems

But if you don't need those features, you can as well just build your executable with go build.

I also tested loading of html files from resource files and it works for me.
Could you provide a small code sample, so I can reproduce the error on my end?

package main

import (
    "crypto/sha1"
    "encoding/hex"
    "fmt"

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

func main() {

    var check string

    for i := 0; i < 1000; i++ {
        var (
            res  string
            file = core.NewQFile2(":/qml/assets/view.html")
        )
        file.Open(core.QIODevice__ReadOnly)
        if file.IsOpen() {
            res = file.ReadAll()
        }
        file.Close()

        var sum = sha1.Sum([]byte(res))
        if i == 0 {
            check = hex.EncodeToString(sum[:])
        }
        if hash := hex.EncodeToString(sum[:]); hash != check {
            fmt.Printf("%v: %v != %v\n", i, hash, check)
        }
    }
}

from qt.

gen2brain avatar gen2brain commented on August 28, 2024

Ok, that is similar to what I was trying to do. Only difference is I had something like this in view.html
<script type="text/javascript" src="qrc:///qml/assets/js/jquery.js"></script>`
I don't have files currently, I will post sample as soon as I can.

I tried already to build moc files with qtmoc, for resource files I saved the ones generated from qtdeploy and go build works. I just don't understand how to use minimal builds, if I use -tags minimal then build complains that it can not find uitools.

from qt.

therecipe avatar therecipe commented on August 28, 2024

Do you use the uitools package in your code?
Does it work if you don't use the minimal tag?

The minimal function, to dynamically rebuild the binding files is currently only executed if you use qtdeploy.
The files are created with a -minimal.* suffix in the core, gui, widgets, uitools, ... folders.

Mabye there are no -minimal.* files in the uitools folder?

from qt.

gen2brain avatar gen2brain commented on August 28, 2024

Yes, I use uitools in code, it worked without minimal tag and after I rebuilt everything with setup.sh it works now also with go build -tags minimal, the resulting binary after strip is same size as in deploy/linux_minimal when qtdeploy is used. I can now try to use it with my static build of Qt.

I cannot reproduce anymore error with loading html file, and I don't try to use webengine anymore, I will just use plain Qt components. The only issue I have now is with LoadFromData2 function as I am trying to load remote images.

Thanks

from qt.

therecipe avatar therecipe commented on August 28, 2024

I will look into this.

from qt.

therecipe avatar therecipe commented on August 28, 2024

Fixed it 2db75f9

This works now https://gist.github.com/gen2brain/2d56084e797d98cf26703142613d438b

from qt.

gen2brain avatar gen2brain commented on August 28, 2024

It works :) Thanks!

from qt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.