質問

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