QFileDialog中的后退和前进按钮没有信号
back and forward button in QFileDialog dont have signals
我正在使用QFileDialog::DontUseNativeDialog。现在我的信号有问题。这是我的示例代码:
class A : public QFileDialog
{
A(){
setOption(QFileDialog::DontUseNativeDialog);
connect(this, SIGNAL(directoryEntered(const Qstring), this, SLOT(foo(const QString)));
}
foo(const QString path){
QDir dir(path);
// Code...
}
};
现在,当我使用DontUseNativeDialog选项时,我在对话框的右上角得到了三个导航按钮,它们是:
1. Back
2. Forward
3. Parent Directory
当我按下Parent Directory按钮时,就会触发信号directoryEntered(const QString)。但在"后退"answers"前进"按钮的情况下,它不起作用。有什么不同的信号我可以用吗。请帮忙。非常感谢。
QFileDialog和Qt4.8.x 也有同样的问题
解决方案是在点击按钮时手动发出信号:
class FileDialog : public QFileDialog {
public:
FileDialog() : QFileDialog() {
this->fixHistoryButtons();
}
private:
void fixHistoryButtons() {
QToolButton backButton = this->findChild<QToolButton *>("backButton");
QToolButton forwardButton = this->findChild<QToolButton *>("forwardButton");
this->connect(backButton, SIGNAL(clicked()), SLOT(backOrForwardButtonClicked()));
this->connect(forwardButton, SIGNAL(clicked()), SLOT(backOrForwardButtonClicked()));
}
private slots:
void backOrForwardButtonClicked() {
/* this->directory() should be save, since we should be called after QFileDialog has done it's thing */
emit this->directoryChanged( this->directory().absolutePath() );
}
};
相关文章:
- Qt VTK交互风格的信号到小部件
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 问:如何使用C++中的按钮从窗口打开窗口
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- 将QPush按钮::单击信号到插槽时出错
- 按钮组上的 Qt 信号未连接
- QT按钮组和可检查的按钮:如何将切换信号与整数和布尔值连接?
- 如何在按下按钮时捕获捆绑的 GDB 发出的信号"stop"?
- 无法从抽象类调用按钮信号
- QT qml 按钮发出信号单击,尽管已禁用
- 右键单击按钮GTKMM-3.0的信号
- C++中按钮的简单信号
- QFileDialog中的后退和前进按钮没有信号
- 从C++代码发出 BB 级联按钮的"clicked()"信号
- (Qt)从按钮的QButtonGroup创建信号
- 在Visual Studio中按下"停止调试"按钮时拦截信号/事件
- GTKmm:程序崩溃时,试图连接按钮点击信号
- Qt不需要的双执行按钮按下的信号
- Qt如何使一个按钮响应时,插槽连接到它的click()信号正在运行
- 处理来自动态按钮阵列的信号