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. Mac Printing: device name versus queue name
Forum Updated to NodeBB v4.3 + New Features

Mac Printing: device name versus queue name

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.2k Views 1 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.
  • F Offline
    F Offline
    fredrossperry
    wrote on 11 Oct 2014, 18:16 last edited by
    #1

    I am using QPrintDialog for the user to choose a printer, but using CUPS to do the actual printing.
    This works fine, but does not launch the corresponding print queue app. So I am trying to do that.

    Each print queue has an app in ~/Library/Printers, named the same as the queue.
    My issue is that QPrintDialog returns a QPrinter whose name is the name of the print device, not the queue.
    For example, I have a printer whose device name is "_192_168_1_7", but the queue name is "HP LaserJet 6P"

    So, I need a way to find the queue name from the device name. Thanks.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 11 Oct 2014, 20:50 last edited by
      #2

      Hi,

      Sounds like this "report":https://bugreports.qt-project.org/browse/QTBUG-3138 you might want to add a comment on it about your use case

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fredrossperry
        wrote on 12 Oct 2014, 19:15 last edited by
        #3

        Thanks, I added a comment to the bug you mentioned. What I would up doing was, calling the CUPS function to list available printers (cupsGetDests). This returns available printers, along with a list of options for each. Among the options is "printer-info", which appears to hold the queue name.

        @
        QString queueName("");

            cups_dest_t *dests = NULL;
            int numDests = cupsGetDests(&dests);
            for (int i = 0; i < numDests; i++)
            {
                cups_dest_t dest = dests[i];
                if (printer->printerName().compare(QString(dest.name))==0)
                {
                    for (int j = 0; j < dest.num_options; j++)
                    {
                        cups_option_t opt = dest.options[j];
                        if (QString(opt.name).compare(QString("printer-info"))==0)
                        {
                            queueName = QString(opt.value);
                            break;
                        }
                    }
                }
                if (!queueName.isEmpty())
                    break;
            }
            cupsFreeDests(numDests, dests);
        

        @

        [edit: added missing coding tags @ SGaist]

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 12 Oct 2014, 21:13 last edited by
          #4

          If you have the time for it you could add that API yourself to QPrinter and make it a part of Qt

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          1/4

          11 Oct 2014, 18:16

          • Login

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