سؤال

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();
}
هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top