本文介绍了如何在 QWizard 中完全禁用或隐藏后退按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 QWizard 对话框中禁用或隐藏后退按钮.我该怎么做?

I want to disable or hide Back button in QWizard dialog. How can I do it?

推荐答案

我查看了 Qt 的源代码,发现可以通过创建自定义按钮布局并在列表中省略后退按钮来隐藏后退按钮:

I've looked at Qt's sources and found out that it's possible to hide Back button by creating custom button layout and ommiting Back button in the list:

  QList<QWizard::WizardButton> button_layout;
  button_layout << QWizard::HelpButton << QWizard::Stretch <<
                   QWizard::NextButton << QWizard::CustomButton1 <<
                   QWizard::CancelButton;
  this->setButtonLayout(button_layout);

我希望这会为某人节省一些时间.

I hope this will save some time to somebody.

附言

AFAIU 为了避免使用 QTimer,需要修改 QWizard 源代码.最简单的方法是添加一个虚函数虚拟无效按钮Updated();并从 QWizard 的末尾调用它:void QWizardPrivate::_q_updateButtonStates()然后在你的 QWizard 子类中重新实现这个 buttonUpdated() 并在那里禁用后退按钮.

AFAIU to avoid using QTimer it is needed to modify QWizard source code. The easies way will be to add a virtual functionvirtual void buttonsUpdated();and call it from the end of QWizard's:void QWizardPrivate::_q_updateButtonStates()Then reimplement this buttonsUpdated() in your QWizard sublass and disable Back button there.

这篇关于如何在 QWizard 中完全禁用或隐藏后退按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-27 07:57