簡體   English   中英

部署Qt應用程序時缺少功能

[英]Missing functionalities when deploying Qt application

我為Qt gui應用程序創建了一個deploy文件夾,我添加了他尖叫的所有.dll。 該應用程序正在運行,但是缺少2個功能。

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());
}

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);
        }
    }

在帶有deploy文件夾的計算機上,兩個對話框均未顯示。 當我在要構建應用程序的PC上的Qt Creator中運行此程序時,這些對話框將正常工作。 我猜想我需要包括一些其他的庫,但是我不知道哪個庫,因為該應用程序不會引發任何錯誤,它只是不顯示對話框。 我會盡力幫助。

您的問題與庫無關。

很明顯,第一種方法在這里返回:

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

第二個沒有進入

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

對於第一個文件,我建議您打印以記錄文件名,如果是這種情況,請將代碼更改為此:

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

如果問題不與文件路徑有關,則應檢查文件的權限。 並編寫如下內容:

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

對於第二個,您絕對應該添加:

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

不幸的是,關於第二個錯誤,您沒有提供足夠的數據,我不能說出真正的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM