0

I'm using go-qt bindings (therecipe). I faced such a problem that I cannot bring the window with the file dialog forward, I tried all the functions (and their combinations) that I could find on the Internet, but none of them did not help bring the dialog up.

I try to use this function:

fileDialog.SetWindowFlag(core.Qt__WindowStaysOnTopHint,true)
fileDialog.ActivateWindow()
fileDialog.SetWindowState(core.Qt__WindowActive)
fileDialog.SetWindowState(core.Qt__WindowMinimized|core.Qt__WindowActive)
fileDialog.Raise()
fileDialog.SetFocus2()

I also noticed a feature that if you call the dialog again after fileDialog.Exec (), then it will be displayed on top of all windows as needed.

code for this case

var fileDialog = widgets.NewQFileDialog2(nil, "Open Directory", "", "")

    if fileDialog.Exec() != int(widgets.QDialog__Accepted) {
        return
    }

    if fileDialog.Exec() != int(widgets.QDialog__Accepted) {
        return
    }

Code for function where I'm using Dialog:

func choseFile(){

var fileDialog = widgets.NewQFileDialog2(nil, "Open Directory", "", "")
fileDialog.SetAcceptMode(widgets.QFileDialog__AcceptOpen)
fileDialog.SetFileMode(widgets.QFileDialog__ExistingFile)
fileDialog.SetWindowFlag(core.Qt__WindowStaysOnTopHint,true)

if fileDialog.Exec() != int(widgets.QDialog__Accepted) {
    return
}

fmt.Println(fileDialog.SelectedFiles()[0])

}

rf.rvr
  • 1
  • 1
  • [This](https://stackoverflow.com/a/49157020/720999)? – kostix Aug 21 '20 at 11:50
  • This did not specifically solve my problem, but I was able to find a solution thanks to this. – rf.rvr Aug 21 '20 at 12:27
  • Some wrote that the problem might be related to native dialogs (in my case I am using ubuntu), so I put the flag DontUseNativeDialog. Then the problem was solved. widgets.QFileDialog_GetOpenFileName(ac.MainWindow,"Open Directory","","","",widgets.QFileDialog__DontUseNativeDialog) – rf.rvr Aug 21 '20 at 12:27

1 Answers1

0

Problem might be related to native dialogs (in my case I am using ubuntu), so I put the flag DontUseNativeDialog. Then the problem was solved.

filename := widgets.QFileDialog_GetOpenFileName(ac.MainWindow,"Open Directory","","","",widgets.QFileDialog__DontUseNativeDialog)

upd: Its works even if the first argument is nil.

rf.rvr
  • 1
  • 1