Customizing QPrintDialog - Need to remove access to disk storage
-
wrote on 6 Dec 2023, 02:05 last edited by James S. 12 Jun 2023, 02:09
0
I need to customize the QPrintDialog in the Qt framework. The default view has controls that give access to local storage on the device. All access to local disks must be disabled on the dialog.
This software runs on Linux.
Is it safe to iterate over child widgets on the QPrintDialog and disable or remove all controls used for accessing the disk?
Example:
auto childrenList = printDialog->children (); for(auto obj : childrenList) { if(obj->isWidgetType ()) { ... if(qobject_cast<QComboBox*>(obj)) { qobject_cast<QComboBox*>(obj)->removeItem (1); qobject_cast<QComboBox*>(obj)->setEnabled (false); } if(qobject_cast<QLabel*>(obj)) { qobject_cast<QLabel*>(obj)->setEnabled (false); qobject_cast<QLabel*>(obj)->setText (""); qobject_cast<QLabel*>(obj)->setParent (parent); } if(qobject_cast<QLineEdit*>(obj)) { qobject_cast<QLineEdit*>(obj)->setEnabled (false); qobject_cast<QLineEdit*>(obj)->setText (""); qobject_cast<QLineEdit*>(obj)->setParent (parent); qobject_cast<QLineEdit*>(obj)->hide (); } ... } }
-
0
I need to customize the QPrintDialog in the Qt framework. The default view has controls that give access to local storage on the device. All access to local disks must be disabled on the dialog.
This software runs on Linux.
Is it safe to iterate over child widgets on the QPrintDialog and disable or remove all controls used for accessing the disk?
Example:
auto childrenList = printDialog->children (); for(auto obj : childrenList) { if(obj->isWidgetType ()) { ... if(qobject_cast<QComboBox*>(obj)) { qobject_cast<QComboBox*>(obj)->removeItem (1); qobject_cast<QComboBox*>(obj)->setEnabled (false); } if(qobject_cast<QLabel*>(obj)) { qobject_cast<QLabel*>(obj)->setEnabled (false); qobject_cast<QLabel*>(obj)->setText (""); qobject_cast<QLabel*>(obj)->setParent (parent); } if(qobject_cast<QLineEdit*>(obj)) { qobject_cast<QLineEdit*>(obj)->setEnabled (false); qobject_cast<QLineEdit*>(obj)->setText (""); qobject_cast<QLineEdit*>(obj)->setParent (parent); qobject_cast<QLineEdit*>(obj)->hide (); } ... } }
wrote on 6 Dec 2023, 13:23 last edited by@James-S Hi,
I think faster and safer way is to create your own, simple dialog? You can enumerate printers, put names into widget list and let user select one? -
0
I need to customize the QPrintDialog in the Qt framework. The default view has controls that give access to local storage on the device. All access to local disks must be disabled on the dialog.
This software runs on Linux.
Is it safe to iterate over child widgets on the QPrintDialog and disable or remove all controls used for accessing the disk?
Example:
auto childrenList = printDialog->children (); for(auto obj : childrenList) { if(obj->isWidgetType ()) { ... if(qobject_cast<QComboBox*>(obj)) { qobject_cast<QComboBox*>(obj)->removeItem (1); qobject_cast<QComboBox*>(obj)->setEnabled (false); } if(qobject_cast<QLabel*>(obj)) { qobject_cast<QLabel*>(obj)->setEnabled (false); qobject_cast<QLabel*>(obj)->setText (""); qobject_cast<QLabel*>(obj)->setParent (parent); } if(qobject_cast<QLineEdit*>(obj)) { qobject_cast<QLineEdit*>(obj)->setEnabled (false); qobject_cast<QLineEdit*>(obj)->setText (""); qobject_cast<QLineEdit*>(obj)->setParent (parent); qobject_cast<QLineEdit*>(obj)->hide (); } ... } }
wrote on 7 Dec 2023, 06:54 last edited by@James-S said in Customizing QPrintDialog - Need to remove access to disk storage:
0
I need to customize the QPrintDialog in the Qt framework. The default view has controls that give access to local storage on the device. All access to local disks must be disabled on the dialog.
Is this in reference to the print to file option? That can be turned off with the QAbstractPrintDialog::PrintToFile option. On my X11 test system with no other printer available, the dialog still shows the location as "local file", but the input to select a file is gone.
1/3