新手上路,整了一个非常单纯的小工程(拿 ai 写的),然后在 ui 设计时右键 Pushbutton 转到槽时被这个问题干碎了,一头雾水,甚至不知道怎么排除错误。
编译日志如下:
00:46:54: 为项目 untitled1 执行步骤 …
00:46:54: 正在启动 “G:QtCommunityToolsCMake_64bincmake.exe” –build G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug –target all
[0/2 0.0/sec] Re-checking globbed directories…
[1/9 0.4/sec] Automatic MOC and UIC for target untitled1
[2/9 0.7/sec] Running AUTOMOC file extraction for target untitled1
[3/9 0.9/sec] Running moc –collect-json for target untitled1
[4/9 0.6/sec] Building CXX object CMakeFiles/untitled1.dir/untitled1_autogen/mocs_compilation.cpp.o
[5/9 0.8/sec] Building CXX object CMakeFiles/untitled1.dir/main.cpp.o
[6/9 0.9/sec] Building CXX object CMakeFiles/untitled1.dir/mainwindow.cpp.o
[7/9 0.9/sec] Linking CXX shared module libuntitled1_arm64-v8a.so
[8/9 1.0/sec] Copying untitled1 binary to apk folder
00:47:03: The command “G:QtCommunityToolsCMake_64bincmake.exe –build G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug –target all” finished successfully.
00:47:03: 正在启动 “G:QtCommunity6.9.1mingw_64binandroiddeployqt.exe” –input G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug/android-untitled1-deployment-settings.json –output G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug/android-build-untitled1 –android-platform android-35 –jdk G:/jdk17 –gradle
Generating Android Package
Input file: G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug/android-untitled1-deployment-settings.json
Output directory: G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug/android-build-untitled1/
Application binary: untitled1
Android build platform: android-35
Install to device: No
Skipping createRCC
Starting a Gradle Daemon, 1 incompatible and 9 stopped Daemons could not be reused, use –status for details
Task :preBuild UP-TO-DATE
Task :preDebugBuild UP-TO-DATE
Task :mergeDebugNativeDebugMetadata NO-SOURCE
Task :javaPreCompileDebug
Task :generateDebugResValues
Task :checkDebugAarMetadata
Task :mapDebugSourceSetPaths
Task :generateDebugResources
Task :mergeDebugResources
Task :packageDebugResources
Task :createDebugCompatibleScreenManifests
Task :extractDeepLinksDebug
Task :parseDebugLocalResources
Task :processDebugMainManifest
package=”org.qtproject.example.untitled1″ found in source AndroidManifest.xml: G:QtfileQtProgramuntitled1buildQt_6_9_1_Clang_arm64_v8a-Debugandroid-build-untitled1AndroidManifest.xml.
Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported, and the value is ignored.
Recommendation: remove package=”org.qtproject.example.untitled1″ from the source AndroidManifest.xml: G:QtfileQtProgramuntitled1buildQt_6_9_1_Clang_arm64_v8a-Debugandroid-build-untitled1AndroidManifest.xml.
Task :processDebugManifest
Task :mergeDebugShaders
Task :compileDebugShaders NO-SOURCE
Task :generateDebugAssets UP-TO-DATE
Task :mergeDebugAssets
Task :compressDebugAssets
Task :processDebugJavaRes NO-SOURCE
Task :checkDebugDuplicateClasses
Task :mergeDebugJniLibFolders
Task :mergeLibDexDebug
Task :validateSigningDebug
Task :writeDebugAppMetadata
Task :writeDebugSigningConfigVersions
Task :processDebugManifestForPackage
Task :mergeDebugNativeLibs
Task :mergeDebugJavaResource
Task :processDebugResources
Task :compileDebugJavaWithJavac
Task :dexBuilderDebug
Task :desugarDebugFileDependencies
Task :mergeProjectDexDebug
Task :stripDebugDebugSymbols
Task :mergeExtDexDebug
Task :packageDebug
Task :createDebugApkListingFileRedirect
Task :assembleDebug
[Incubating] Problems report is available at: file:///G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug/android-build-untitled1/build/reports/problems/problems-report.html
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.12/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 23s
33 actionable tasks: 33 executed
Android package built successfully in 28.935 ms.
— File: G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug/android-build-untitled1//build/outputs/apk/debug/android-build-untitled1-debug.apk
00:47:32: The command “G:QtCommunity6.9.1mingw_64binandroiddeployqt.exe –input G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug/android-untitled1-deployment-settings.json –output G:/Qtfile/QtProgram/untitled1/build/Qt_6_9_1_Clang_arm64_v8a-Debug/android-build-untitled1 –android-platform android-35 –jdk G:/jdk17 –gradle –gdbserver” finished successfully.
00:47:32: Elapsed time: 00:38.
mainwindow.h 如下:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QLabel>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
protected:
void mousePressEvent(QMouseEvent *event) override;
private:
QLabel *label;
};
#endif // MAINWINDOW_H
mainwindow.cpp 如下:
#include “mainwindow.h”
#include <QMouseEvent>
#include <QFont>
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
// 设置窗口大小
resize(400, 300);
// 创建 label 但先不显示文字
label = new QLabel(this);
label->setText("");
label->setAlignment(Qt::AlignCenter);
label->setGeometry(rect()); // 占满整个窗口
label->setFont(QFont("Arial", 24));
}
MainWindow::~MainWindow()
{
}
void MainWindow::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
label->setText(“Hello World”);
qDebug() << “屏幕被点击,显示 Hello World”;
}
Leave a Reply Cancel reply