【问题标题】:Qt Designer causes no changes in the applicationQt Designer 不会导致应用程序发生任何变化
【发布时间】:2014-06-14 23:57:14
【问题描述】:

我一直在尝试使用 Qt Quick Application 在 Qt Designer 中制作一个简单的测试应用程序。但是,当我运行它时,我在 Qt 设计器中实现的任何内容都不会显示。例如,“Testing Qt Designer”文本没有出现,因为我在设计器中实现了它。我试图清理构建,并再次构建它。我还删除了整个构建文件夹并尝试再次构建它,但这不起作用。谁能帮我让 Qt Designer 工作?

我在 Windows 8.1 64 位上使用 Qt Creator 5.3。

main.qml:

import QtQuick 2.2
import QtQuick.Controls 1.1

ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")

menuBar: MenuBar {
    Menu {
        title: qsTr("File")
        MenuItem {
            text: qsTr("Exit")
            onTriggered: Qt.quit();
        }
    }
}

Text {
    text: qsTr("Hello World")
    anchors.centerIn: parent
}

Text {
    id: text1
    x: -258
    y: -151
    width: 264
    height: 76
    text: qsTr("Testing Qt Designer")
    font.pixelSize: 25
}
}

main.cpp:

#include <QApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));

return app.exec();
}

testApp5.pro:

TEMPLATE = app

QT += qml quick widgets

SOURCES += main.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Default rules for deployment.
include(deployment.pri)

deployment.pri:

android-no-sdk {
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
x86 {
    target.path = /libs/x86
} else: armeabi-v7a {
    target.path = /libs/armeabi-v7a
} else {
    target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:unix {
isEmpty(target.path) {
    qnx {
        target.path = /tmp/$${TARGET}/bin
    } else {
        target.path = /opt/$${TARGET}/bin
    }
    export(target.path)
}
INSTALLS += target
}

export(INSTALLS)

【问题讨论】:

    标签: c++ qt


    【解决方案1】:

    我最近有时会遇到一个奇怪的问题,看起来基于 qrc 的部署失败了;更改的文件不会导致 rcc 运行,因此您的应用程序不会反映您所做的更改。它似乎与QTBUG-13334相似

    您可以通过编辑器或设计器更改您的 QML 文件,然后检查 Compile Output 窗口来验证您是否遇到此问题。如果你看到类似的东西

    mingw32-make[1]: Nothing to be done for 'first'.
    

    即使在部署之前进行了更改,您也可能会遇到此问题。

    解决方法

    尝试转到Projects &gt; Run 并在Deployment 下单击Add Deploy Step,然后选择Make。在Make arguments 字段中,输入“干净”。然后添加另一个Make 部署步骤,这次没有参数。这将迫使您在每次运行应用程序时重新构建您的项目 - 对于小型项目来说这不是什么大问题。

    请注意,如果您希望多次重新运行应用程序,Application Output 窗口中的plain green arrow 将直接运行应用程序的可执行文件,绕过任何部署步骤。

    【讨论】:

    • 看起来我的“编译输出”窗口中没有该输出。无论如何,我尝试了解决方法,但也没有用。
    猜你喜欢
    • 2021-11-14
    • 1970-01-01
    • 2010-09-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多