Mac Printing: device name versus queue name



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


  • Lifetime Qt Champion

    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



  • 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]


  • Lifetime Qt Champion

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.