same
same

Reputation: 51

Customizing QPrintPreviewDialog

Is it possible to customize QPrintPreviewDialog?

I want to delimitate zoom in and zoom out functions.

Upvotes: 2

Views: 1482

Answers (2)

Hilko
Hilko

Reputation: 21

Thanks it works fine.

Every menu entry can accessed.

    QList<QToolBar *> toolbarlist = priview.findChildren<QToolBar *>();
    foreach(auto tool, toolbarlist )
    { 
        tool->setDisabled(true); 
   }

Upvotes: 2

Alastair Gordon
Alastair Gordon

Reputation: 96

I know this question is a few months old but it took me a fair while to figure it out so here it is:

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"));
}

Upvotes: 5

Related Questions