Im working on a Qt project. Everything has been working perfectly untill I opened application this morning. I got error: «QtRunWork» task returned false but did not log an error. Im using VS2019 with QtExtension.
This is output:
1>Moc'ing ..srcmainwindow.h...
1>Moc'ing ..srcsettingsdialog.h...
1> moc: Unknown compiler flavor 'msvc;msvc'; valid values are: msvc, unix.
1> Usage: C:/Qt/5.15.1/msvc2019_64/bin/moc [options] [header-file] [@option-file] [MOC generated json file]
1> Qt Meta Object Compiler version 67 (Qt 5.15.1)
1> Options:
1> -?, -h, --help Displays help on commandline options.
1> --help-all Displays help including Qt specific
1> options.
1> -v, --version Displays version information.
1> -o <file> Write output to file rather than stdout.
1> -I <dir> Add dir to the include path for header
1> files.
1> -F <framework> Add Mac framework to the include path for
1> header files.
1> -E Preprocess only; do not generate meta
1> object code.
1> -D <macro[=def]> Define macro, with optional definition.
1> -U <macro> Undefine macro.
1> -M <key=value> Add key/value pair to plugin meta data
1> --compiler-flavor <flavor> Set the compiler flavor: either "msvc" or
1> "unix".
1> -i Do not generate an #include statement.
1> -p <path> Path prefix for included file.
1> -f <file> Force #include <file> (overwrite default).
1> -b <file> Prepend #include <file> (preserve default
1> include).
1> --include <file> Parse <file> as an #include before the main
1> source(s).
1> -n <which> Do not display notes (-nn) or warnings
1> (-nw). Compatibility option.
1> --no-notes Do not display notes.
1> --no-warnings Do not display warnings (implies
1> --no-notes).
1> --ignore-option-clashes Ignore all options that conflict with
1> compilers, like -pthread conflicting with
1> moc's -p option.
1> --output-json In addition to generating C++ code, create
1> a machine-readable JSON file in a file that
1> matches the output file and an extra .json
1> extension.
1> --collect-json Instead of processing C++ code, collect
1> previously generated JSON output into a
1> single file.
1> --output-dep-file Output a Make-style dep file for build
1> system consumption.
1> --dep-file-path <file> Path where to write the dep file.
1> --dep-file-rule-name <rule name> The rule name (first line) of the dep file.
1> Arguments:
1> [header-file] Header file to read from, otherwise stdin.
1> [@option-file] Read additional options from option-file.
1> [MOC generated json file] MOC generated json output
1>Moc'ing ..srcdeviceManager.h...
1>Moc'ing ..srctreemodel.h...
1>C:UsersuserAppDataLocalQtMsBuildqt_globals.targets(268,5): error MSB4181: The "QtRunWork" task returned false but did not log an error.
1>Done building project "project.vcxproj" -- FAILED.
I’ve tried changing compiler flavor but have not managed to do it. I tried changing it in Qt Project Settings, but it did not do anything. Thank you for your time.
Edit: Out of about 20 .h I’ve tracked the one that gives this error when trying to compile in VS2019 using Qt Extension. Have no idea how to fix this error.
Recently in business development need to update the UI in the QThread, if the UI handle through the direct update will make the program reported an error, because the update of the UI in the thread will not be captured by the original thread of the EXEC event, will lead to message event blockage generated ERROR, so the use of the signal and slot mechanism, and then I declared a signals signal in the QThread, the compilation reported this error.
The "QtRunWork" task returned false but did not log an error
No detailed warning was given, and I later checked the relevant QT instructions to solve the problem.
Solution: Add a line of macro definition to the class where you use signals and slots.
Q_OBJECT
This will work, the signal and slotted based on Q_OBJECT, we need to declare it module to our class so that the QT compiler can instantiate it, otherwise it will be exception ERROR.
Read More:
Project configuration: VS2019+Qt plug-in.
Problem Description:
Suddenly an error was reported when running a project today:
ERROR MSB4181 QtRunwork returned false, but no error was logged
problem causes: Qt extended version is automatically updated, and the new Qt is not compatible;
Solution: VS extension above —> Manage extension —> Uninstall the current Qt plug-in, and then reinstall the previous Qt plug-in. Remember to turn off the automatic update to prevent the same problem from happening again.
Я работаю над проектом Qt. Все работало отлично, пока я не открыл приложение сегодня утром. Я получил ошибку: задача «QtRunWork» вернула false, но не зарегистрировала ошибку. Я использую VS2019 с QtExtension.
Это вывод:
1>Moc'ing ..srcmainwindow.h...
1>Moc'ing ..srcsettingsdialog.h...
1> moc: Unknown compiler flavor 'msvc;msvc'; valid values are: msvc, unix.
1> Usage: C:/Qt/5.15.1/msvc2019_64/bin/moc [options] [header-file] [@option-file] [MOC generated json file]
1> Qt Meta Object Compiler version 67 (Qt 5.15.1)
1> Options:
1> -?, -h, --help Displays help on commandline options.
1> --help-all Displays help including Qt specific
1> options.
1> -v, --version Displays version information.
1> -o <file> Write output to file rather than stdout.
1> -I <dir> Add dir to the include path for header
1> files.
1> -F <framework> Add Mac framework to the include path for
1> header files.
1> -E Preprocess only; do not generate meta
1> object code.
1> -D <macro[=def]> Define macro, with optional definition.
1> -U <macro> Undefine macro.
1> -M <key=value> Add key/value pair to plugin meta data
1> --compiler-flavor <flavor> Set the compiler flavor: either "msvc" or
1> "unix".
1> -i Do not generate an #include statement.
1> -p <path> Path prefix for included file.
1> -f <file> Force #include <file> (overwrite default).
1> -b <file> Prepend #include <file> (preserve default
1> include).
1> --include <file> Parse <file> as an #include before the main
1> source(s).
1> -n <which> Do not display notes (-nn) or warnings
1> (-nw). Compatibility option.
1> --no-notes Do not display notes.
1> --no-warnings Do not display warnings (implies
1> --no-notes).
1> --ignore-option-clashes Ignore all options that conflict with
1> compilers, like -pthread conflicting with
1> moc's -p option.
1> --output-json In addition to generating C++ code, create
1> a machine-readable JSON file in a file that
1> matches the output file and an extra .json
1> extension.
1> --collect-json Instead of processing C++ code, collect
1> previously generated JSON output into a
1> single file.
1> --output-dep-file Output a Make-style dep file for build
1> system consumption.
1> --dep-file-path <file> Path where to write the dep file.
1> --dep-file-rule-name <rule name> The rule name (first line) of the dep file.
1> Arguments:
1> [header-file] Header file to read from, otherwise stdin.
1> [@option-file] Read additional options from option-file.
1> [MOC generated json file] MOC generated json output
1>Moc'ing ..srcdeviceManager.h...
1>Moc'ing ..srctreemodel.h...
1>C:UsersuserAppDataLocalQtMsBuildqt_globals.targets(268,5): error MSB4181: The "QtRunWork" task returned false but did not log an error.
1>Done building project "project.vcxproj" -- FAILED.
Я пробовал изменить вкус компилятора, но не смог. Я попытался изменить его в настройках проекта Qt, но ничего не вышло. Спасибо за уделенное время.
Изменить: из примерно 20 .h я отследил тот, который дает эту ошибку при попытке компиляции в VS2019 с использованием Qt Extension. Не знаю, как исправить эту ошибку.
3 ответа
Лучший ответ
Я удалил инструмент Qt VS из Visual Studio и установил предыдущую версию инструмента Qt VS.
Вы можете найти его здесь: https://download.qt.io/official_releases/vsaddin /2.5.2/
Это подходит для меня. Может проблема с новой версией
Изменить: не забудьте отключить автообновление
2
Kevin B Burns
29 Сен 2020 в 05:47
Помогло перегрузить макрос Q_OBJECT Было
class CXXX: public CTTT
{
Q_OBJECT
Стал
class CXXX: public CTTT
{
//Q_OBJECT
-1
user3753619
6 Окт 2020 в 07:33
Я была такая же проблема.
Случайно у меня был нормальный int
, заявленный под моим public slots:
. Перевод в нормальный режим public:
помог мне и решил проблему.
Надеюсь, это сработает и для вас.
0
David Fischer
21 Окт 2020 в 22:23
Since the update to Qt 2.6.0.6, I have a compilation error with project which contain .ui files and .qrc files.
If I compile each file, it works.
But when I rebuild the whole project, I have this error :
1>------ Build started: Project: XXXXX, Configuration: Debug x64 ------ 1>Uic'ing FormYYYYY.ui... 1>Uic'ing FormZZZZZZ.ui... 1>Uic'ing FormWWWWWW.ui... 1>Rcc'ing ResXXXX.qrc... 1> RCC Parse Error: 'XXXXFormYYYYY.ui' Line: 2 Column: 18 [unexpected tag: ui] 1>C:Users....AppDataLocalQtMsBuildqt_globals.targets(280,5): error MSB4181: The "QtRunWork" task returned false but did not log an error. 1>Done building project "XXXXX.vcxproj" -- FAILED.
Note that the file YYYYY.ui is correct, the error is when recreation the rcc_XXXXX.cpp
I joined the .ui file which seems fine from my perspective.