Question

I am updating the printer list using availablePrinters(). But it fails to list the new printer added while running application. It is working fine with Qt 4.

The code can be seen below:

#include <QCoreApplication>
#include <QtPrintSupport/QPrinterInfo>
#include <QThread>
#include <QDebug>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    while (1) {
        QThread::msleep(3000);
        qDebug()<<"List of printers";
        QList<QPrinterInfo> printerList=QPrinterInfo::availablePrinters();
        foreach (QPrinterInfo printerInfo, printerList) {
            qDebug()<<printerInfo.printerName();
        }

    }
    return a.exec();
}
Était-ce utile?

La solution

That was a bug with the existing Qt version, and It got fixed on the next version

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top