QFileDialog打开另一个(可能是父)不需要的窗口
此问题可能是由于未正确定义父窗口小部件.在QT手册或在线示例中,传递给QFileDialog :: getOpenFileName(或类似函数)的第一个参数通常为"this".就我而言,如果我用"this"调用以下函数,它将打开对话框和另一个不包含任何内容且标题与可执行文件名称相同的窗口.我试图摆脱第二个不需要的窗口,但没有成功.我用"gui :: parentWidget()"或"0"替换了"this",仍然是同样的问题.另外,如果我没记错的话,在将QT更新到5.0.2版之前,我没有这个问题.任何帮助将不胜感激.
Probably this issue is due to not defining parent widget properly. In QT manual or examples available online, first argument passed to QFileDialog::getOpenFileName (or similar functions) is generally "this". In my case, if I call following function with "this", it will open the dialog box and another window that doesn't contain anything and has a title which is the same as the name of executable file. I tried to get rid of the second unwanted window with no success. I replaced "this" with "gui::parentWidget()" or "0", still same issue. Also if I remember correctly I didn't have this issue before updating QT to version 5.0.2. Any help would be appreciated.
void gui::on_coordinatesBrowse_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,"Open File");
//.....
}
我有:
gui::gui(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::gui)
{
ui->setupUi(this);
//.....
}
和
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
gui mainW;
mainW.show();
return a.exec();
}
我认为我也在Linux上的Qt5.4.0 x64上也遇到了这个问题.
I thought i am also experiencing this on Qt5.4.0 x64 on Linux.
我用QtCreator创建了类似的情况,并在小部件编辑模式(F3)中使用了转到插槽..."上下文菜单,该菜单为我自动创建了一个插槽.
I created a similar situation with QtCreator and used the "go to slot..." context menu in widget edit mode (F3) which created a slot automatically for me.
然后,我重命名了按钮,重命名了功能,并在.ui文件中使用了插槽编辑模式(F3).由于仅显示了通过插槽编辑模式进行的连接,因此我认为我已经准备就绪.但是旧的连接仍然存在,导致出现两个信号...
Then i renamed the buttons and renamed the functions and used the slot edit mode (F3) in the .ui file. Since only the connection via the slot edit mode shows up, i thought i was all set. But the old connection was still existing, resulting in two signals...