c++qtdeploymentprintingabout-box

Missing functionalities when deploying Qt application


I have created a deploy folder for my Qt gui application, I have added all DLLs it screamed for. The app is running, but there 2 functionalities that are missing.

void MainWindow::on_action_About_triggered()
{
    QString filePatch = QApplication::applicationDirPath() + "/changelog.txt";
    QFile f(filePatch);
    if (!f.open(QFile::ReadOnly | QFile::Text))
        return;

    QTextStream in(&f);
    QMessageBox::about(this, tr("About testapp"),
                getAppVersion() + "\ntestapp\n\n" + in.readAll());
}

And

QPrinter printer;
    printer.setFullPage(true);
    printer.setPaperSize(QPrinter::A4);
    printer.setOrientation(QPrinter::Landscape);

    if (SpecialTypes::printType_t::ePrint == pType)
    {
        printer.setOutputFormat(QPrinter::NativeFormat);

        QPrintDialog printDial(&printer, this);
        if (printDial.exec() == QDialog::Accepted)
        {
            textEdit->document()->print(&printer);
        }
    }

Both dialogs are not showing on a computer with the deploy folder. When I run this in Qt creator on the pc I am building the app on, those dialogs work properly. I guess I need to include some additional libraries, but I have no idea which ones, as the app doesn't throw any error, it just doesn't show the dialogs.


Solution

  • Your problems have nothing to do with libraries.

    The first method, obviously, returns here:

    if (!f.open(QFile::ReadOnly | QFile::Text))
        return;
    

    The second one doesn't get inside of

    if (SpecialTypes::printType_t::ePrint == pType)
    

    With the first one I'd recommend you to print to log the file name, and, if this is the case, change code to this:

    QDir dir(QApplication::applicationDirPath());
    QFile f(dir.absoluteFilePath("changelog.txt"));
    

    If the problem isn't connected to the file path, then you should check file's permissions. And write something like this:

    if (!f.open(QFile::ReadOnly | QFile::Text)) {
        qDebug() << "Error opening file. Error code =" << f.error();
        return;
    }
    

    For the second one you should definitely add:

    } else {
        qDebug() << "SpecialTypes::printType_t::ePrint != pType";
    }
    

    Unfortunatelly, you haven't provided enough data on the second error, and I can't tell the real reason for it.