Domanda

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();
}
È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top