moc

How to automate Qt moc?

旧街凉风 提交于 2019-12-05 15:26:36
I have to run the following commands from Qt command prompt: qmake -project then make and this gives me the debug folder with the Moc file. This is strangely the only way my PC will generate the moc_.cpp file. So how can I automate the task of these commands so I don't have to use these commands again? You should not run qmake -project multiple times. The -project option is meant to provide you a template project file for you to edit. An equivalent of what you are doing in an IDE would be creating a "New Project" every time you want to build. After you have the initial project, you should edit

Qt Moc'ing multiple files in parallel under msbuild

核能气质少年 提交于 2019-12-05 10:05:26
Using the Qt Visual studio plugin it seems to take care of most of almost everything in a seemless manner. Unfortunately it does the moc'ing using a CustomBuild step in msbuild. This results in a serial moc'ing, one after another. Is there a way to convince msbuild to do them in parallel - I'm tired of 7 cores sitting on their laurels like me. I've seen msbuild's BuildInParallel, but I'm not sure how to make that apply here. msbuild snippet: <Project> ... <ItemGroup> <CustomBuild Include="a_class4.h"> <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc

Qt 5 cmake fails with undefined reference to vtable on hello world with inc & src as subdirs

时光毁灭记忆、已成空白 提交于 2019-12-04 02:29:53
Update 2 After messing around a bit (and some editing of the generated Makefiles), it looks like what is happening is that moc is not properly processing MainWindow.h (included by main.cpp and MainWindow.cpp unless it is in the same folder as the source files which included it. Moc runs on MainWindow.cpp , doesn't process the include and thus doesn't see the Q_OBJECT macro so proceeds to produce an empty output file. I'm not sure whether moc usually processes includes or if it just scans the directory, but either way, headers that need mocing but are in other directories are not being

Errors in generated MOC files for QT5 from cmake

断了今生、忘了曾经 提交于 2019-12-03 08:56:47
I generated moc files for QT5 using set (CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) Then I add the moc files into SRC using SET(SRC src/main.cpp src/video_widget_surface.cpp src/video_widget.cpp src/video_player.cpp #moc files moc/moc_video_player.cpp moc/moc_video_widget.cpp moc/moc_video_widget_surface.cpp Finally I add the executable using add_executable(somegui ${SRC}) But I get errors in moc files saying : /other/workspace/perception/somestuff/moc/moc_video_widget.cpp:54:6: error: 'VideoWidget' has not been declared /other/workspace/perception/somestuff/moc/moc_video_widget.cpp

Qt moc error using CMake

让人想犯罪 __ 提交于 2019-12-02 14:44:37
问题 I am trying to write an OpenCV application creating the GUI with Qt and generating the makefiles using CMake. The problem that I have is that when I try to execute the make command, I get the error: This file was generated using the moc from 5.2.1. It cannot be used with the include files from this version of Qt. (The moc has changed too much.) Okay. So I guess I should be trying to use the moc from qt4 rather than qt5 for this (I have both qt4 and qt5 installed). Sure enough I have /usr/bin

Qt moc error using CMake

喜你入骨 提交于 2019-12-02 09:11:58
I am trying to write an OpenCV application creating the GUI with Qt and generating the makefiles using CMake. The problem that I have is that when I try to execute the make command, I get the error: This file was generated using the moc from 5.2.1. It cannot be used with the include files from this version of Qt. (The moc has changed too much.) Okay. So I guess I should be trying to use the moc from qt4 rather than qt5 for this (I have both qt4 and qt5 installed). Sure enough I have /usr/bin/moc-qt4 as well as /usr/bin/moc , so I would have thought all I need to do is invoke sudo update

Using a macro to create QObject derived classes

别等时光非礼了梦想. 提交于 2019-11-30 21:17:24
I'm trying to simplify (i.e. get rid of loads of boilerplate code) the creation of QObject wrapper classes that forward property access of other QObject derived classes. To start small, I'm just trying it with one property: // Sy_test.h - The wrapped class class Sy_test : public QObject { Q_OBJECT Q_PROPERTY( bool prop READ getProp WRITE setProp NOTIFY propChanged ) public: Sy_test( QObject* parent = nullptr ) : QObject{ parent }, prop_{ false } {} bool getProp() const { return prop_; } public slots: void setProp( bool value ) { if ( value != prop_ ) { prop_ = value; emit propChanged( prop_ );

Using a macro to create QObject derived classes

不问归期 提交于 2019-11-30 05:42:30
问题 I'm trying to simplify (i.e. get rid of loads of boilerplate code) the creation of QObject wrapper classes that forward property access of other QObject derived classes. To start small, I'm just trying it with one property: // Sy_test.h - The wrapped class class Sy_test : public QObject { Q_OBJECT Q_PROPERTY( bool prop READ getProp WRITE setProp NOTIFY propChanged ) public: Sy_test( QObject* parent = nullptr ) : QObject{ parent }, prop_{ false } {} bool getProp() const { return prop_; }

信号和槽基本特点

被刻印的时光 ゝ 提交于 2019-11-29 19:14:52
本文链接:https://blog.csdn.net/hhhuang1991/article/details/79829784 信号和槽机制是 QT 的核心机制,要精通QT编程就必须对信号和槽有所了解。 一、使用方法 1. 为控件添加信号和槽 手动添加 //MyDlg.h #pragma once #include <QtWidgets/QDialog> #include <QtWidgets/QLabel> #include <QtWidgets/QLineEdit> #include <QtWidgets/QPushButton> #include <QtWidgets/QMessageBox> #include <QtWidgets/QHBoxLayout> class MyDlg : public QDialog { //只有加入了Q_OBJECT,你才能使用QT中的signal和slot机制。 Q_OBJECT private: QLabel* plabel; QLineEdit* pEdit; QPushButton* pBtn; public slots: void Print(); public: MyDlg(QWidget* parent = Q_NULLPTR); }; //MyDlg.cpp #include "MyDlg.h" #include

Macro expansion in moc

核能气质少年 提交于 2019-11-29 14:36:41
I'd like to store some class info using Q_CLASSINFO macro. However I would like to wrap it in my own macro, for example: #define DB_TABLE( TABLE ) \ Q_CLASSINFO( "db_table", #TABLE ) #define DB_FIELD( PROPERTY, COLUMN ) \ Q_CLASSINFO( "dbcol_" #PROPERTY, #COLUMN ) class Foo : public QObject { Q_OBJECT DB_TABLE( some_table ) DB_FIELD( clientName, client_name ) } Unfortunately, moc doesn't expand macros so the Q_CLASSINFO is not added. I've tried to feed moc with already preprocessed source, but it failes on some included Qt classes. Do you know any workaround for this? andref Other than rolling