自定义 QPrintPreviewDialog

2024-04-01

是否可以自定义PrintPreviewDialog?

我想界定放大和缩小功能。


我知道这个问题已经有几个月了,但我花了相当长的时间才弄清楚,所以这里是:

QPrintPreviewDialog preview(&printer, this);
QList<QToolBar *> toolbarlist = preview.findChildren<QToolBar *>();
if(!toolbarlist.isEmpty())
{
    toolbarlist.first()->actions().at(3)->setDisabled(true);
    toolbarlist.first()->actions().at(4)->setDisabled(true);
    toolbarlist.first()->actions().at(5)->setDisabled(true);
    //or to remove:
    //toolbarlist.first()->removeAction(toolbarlist.first()->actions().at(3));
    //toolbarlist.first()->removeAction(toolbarlist.first()->actions().at(3));
    //toolbarlist.first()->removeAction(toolbarlist.first()->actions().at(3));

    //alternatively you can add actions to the toolbar:
    //toolbarlist.first()->addAction(QIcon("icon.png"), tr("New Action"));
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

自定义 QPrintPreviewDialog 的相关文章

随机推荐