Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Customizing QPrintDialog - Need to remove access to disk storage
QtWS25 Last Chance

Customizing QPrintDialog - Need to remove access to disk storage

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 164 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    James S.
    wrote on last edited by James S.
    #1

    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 ();
             }
             
             ...
       }
    }
    
    artwawA jeremy_kJ 2 Replies Last reply
    0
    • J James S.

      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 ();
               }
               
               ...
         }
      }
      
      artwawA Offline
      artwawA Offline
      artwaw
      wrote on last edited by
      #2

      @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?

      For more information please re-read.

      Kind Regards,
      Artur

      1 Reply Last reply
      0
      • J James S.

        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 ();
                 }
                 
                 ...
           }
        }
        
        jeremy_kJ Offline
        jeremy_kJ Offline
        jeremy_k
        wrote on last edited by
        #3

        @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.

        Asking a question about code? http://eel.is/iso-c++/testcase/

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved