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
Forum Updated to NodeBB v4.3 + New Features

Customizing QPrintDialog - Need to remove access to disk storage

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 170 Views 2 Watching
  • 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 6 Dec 2023, 02:05 last edited by James S. 12 Jun 2023, 02:09
    #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 ();
             }
             
             ...
       }
    }
    
    A J 2 Replies Last reply 6 Dec 2023, 13:23
    0
    • J James S.
      6 Dec 2023, 02:05

      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 ();
               }
               
               ...
         }
      }
      
      A Offline
      A Offline
      artwaw
      wrote on 6 Dec 2023, 13:23 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.
        6 Dec 2023, 02:05

        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 ();
                 }
                 
                 ...
           }
        }
        
        J Online
        J Online
        jeremy_k
        wrote on 7 Dec 2023, 06:54 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

        1/3

        6 Dec 2023, 02:05

        • Login

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