2016-09-27 2 views
0

と呼ばれました動作しません:のQt 5.7 QFileDialogアクションは、私がのFileDialogこのコードの私のメインウィンドウ内

QAction *actionWithShortcut = new QAction(); 
actionWithShortcut->setShortcut(Qt::CTRL + Qt::Key_9); 
actionWithShortcut->setShortcutContext(Qt::ShortcutContext::WidgetWithChildrenShortcut); 
// added this comment to check does it work at list outside filedialog 
// addAction(actionWithShortcut); 
QFileDialog *fd = new QFileDialog(this); 
fd->addAction(actionWithShortcut); 
connect(actionWithShortcut, &QAction::triggered, fd, &QFileDialog::reject); 
fd->show(); 

しかし、私はQFileDialogに任意のアクションを追加することはできませんか、彼らが何らかの形で省略されているように見えます。助言がありますか? 既にウィンドウのフラグ、オプションなどが試されました。解決策が見つかりません。

答えて

3

デフォルトでは、QFileDialogは、ネイティブダイアログを囲む薄いラッパーです。 Qtはネイティブダイアログの周りにアクションをラップするのに必要な長さには達しませんでした。これは実装が欠けている場合です。あなたは、あなたが選んだプラットフォームで動作するようにQtにパッチを当てて、変更を元に戻すことができます。

非ネイティブファイルダイアログに切り替えると、おそらく動作します。

関連する問題