Coder Social home page Coder Social logo

Comments (4)

therecipe avatar therecipe commented on June 22, 2024

Hey

I'm aware of that, but all bool* parameters are currently ignored.
If you take a look at the widgets.cpp, you will see that the bool won't make it into the final call.

char* QInputDialog_QInputDialog_GetText(void* parent, char* title, char* label, int mode, char* text, int ok, int flags, int inputMethodHints)
{
    return QInputDialog::getText(static_cast<QWidget*>(parent), QString(title), QString(label), static_cast<QLineEdit::EchoMode>(mode), QString(text), NULL, static_cast<Qt::WindowType>(flags), static_cast<Qt::InputMethodHint>(inputMethodHints)).toUtf8().data();
}

I'm planning to make them usuable (change them from bool to *bool on the go side) and also pass them all the way into the c++ call, but I haven't found time for it yet.

But, I tested the code below and it works for me.

So, could you provide me a snipped of your code, so I can reproduce the problem?

package main

import (
    "os"

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

func main() {
    widgets.NewQApplication(len(os.Args), os.Args)

    var button = widgets.NewQPushButton2("open dialog", nil)

    button.ConnectClicked(func(_ bool) {
        button.SetText(widgets.QInputDialog_GetText(button, "Title", "Label", widgets.QLineEdit__Normal, "Text", false, core.Qt__Dialog, core.Qt__ImhNone))
    })

    button.Show()

    widgets.QApplication_Exec()
}

from qt.

testhmaa avatar testhmaa commented on June 22, 2024

I have tested it more trying to extract code however as soon as i rip it away from my code base, it starts acting stable.
I tested the code the below code nearly a 100 times and it crashed just once
so i assume the problem is still there.

package main

import (
    "os"
    "fmt"
    "github.com/therecipe/qt/core"
    "github.com/therecipe/qt/widgets"
)


 func main() {

        widgets.NewQApplication(len(os.Args), os.Args)

        var widget = widgets.NewQWidget(nil, 0)

//this crashes because of boolean paramter which should be a pointer
        var u = widgets.QInputDialog_GetText(widget, "title Enter username", "Enter username",
            widgets.QLineEdit__Normal, "", true, core.Qt__Dialog, core.Qt__ImhNone)

        fmt.Printf("user entered %s\n", u) 

}

from qt.

5k3105 avatar 5k3105 commented on June 22, 2024

triple tilde and the word 'go' to get syntax hilight

from qt.

therecipe avatar therecipe commented on June 22, 2024

Hey

I looked into this again and tested the static function QInputDialog::getText manually (100 times), but it didn't crash.
And I also used the code below to test if a manually created QInputDialog would crash, but it didn't.

I'm using go1.7beta1 darwin/amd64, OS X 10.11.5 and Qt 5.7

Please try to find an example which crashes more often.

package main

import (
    "fmt"
    "os"
    "time"

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

func main() {
    widgets.NewQApplication(len(os.Args), os.Args)

    var widget = widgets.NewQWidget(nil, 0)

    for i := 0; i < 200; i++ {

        var dialog = widgets.NewQInputDialog(widget, core.Qt__Dialog)
        dialog.SetWindowTitle("title Enter username")
        dialog.SetLabelText("Enter username")
        dialog.SetTextEchoMode(widgets.QLineEdit__Normal)
        dialog.SetInputMethodHints(core.Qt__ImhNone)

        dialog.ConnectAccept(func() {
            fmt.Printf("user entered %s\n", dialog.TextValue())
            dialog.AcceptDefault()
        })

        go func() {
            time.Sleep(25 * time.Millisecond)

            dialog.SetTextValue(fmt.Sprint(i))

            dialog.Accept()
        }()

        dialog.Exec()
    }
}

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.