moc

Could I have copy constructor for subclass of QObject?

喜你入骨 提交于 2020-01-09 10:53:19
问题 Here we can read that no copy construct and copy assignment operator evaluable. But here we can read that qRegisterMetaType and Q_DECLARE_METATYPE have to have public default constructor, public copy constructor and public destructor. The question is: who is telling a lie? Or I did not understand it correctly? 回答1: Everything is true: 1. QObject can't be copied and all its descendants can't be copied also. 2. Q_DECLARE_METATYPE accepts objects with public constructor, copy constructor and

How to automate Qt moc?

爱⌒轻易说出口 提交于 2020-01-02 06:37:24
问题 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? 回答1: 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

How to automate Qt moc?

Deadly 提交于 2020-01-02 06:37:13
问题 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? 回答1: 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

Qt Vs addin - .obj files are not generated for moc_*.cpp files

有些话、适合烂在心里 提交于 2019-12-25 01:55:51
问题 I am using Visual Studio with qt addin and when I build my project, it generates moc_*.cpp files as a result of build rule in my project : <Tool Name="VCCustomBuildTool" Description="Moc&apos;ing $(InputFileName)..." CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o .\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp (continues..) AdditionalDependencies="$(QTDIR)\bin\moc.exe;.\myfilewithqobject.h" Outputs=".\GeneratedFiles\$(ConfigurationName)\moc_myfilewithqobject.cpp"/> After

MOC adding namespace to class names

允我心安 提交于 2019-12-24 00:48:36
问题 I have this very strange problem while compiling the project. MOC seems to be adding a namespace to the class name being moc'ed, although it's not mentioned anywhere in the file/class. The namespace, however, exists in a library which I use, but it's hidden far away in the header files and I don't use it in the UI files. This is what MOC generates: const QMetaObject SmpTl::CaptureController::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_SmpTl__CaptureController, qt

Get a number of resources asynchronously and “asynchronously” save them to a database. Which good pattern to use? (AFNetworking, Core Data)

谁都会走 提交于 2019-12-22 14:47:14
问题 I need to populate my map with annotations. Each annotation has corresponding Place resource that is being fetched from remote server. Each Place has associated Category - it is fetched from the server too as a separate resource. Let's assume that to populate a given region I need to fetch 100 places, each belonging to the one of 20 categories (actually there are much more of them). I use AFNetworking to fetch the both of resources. I try to cache both places and categories for offline use,

Multiple definitions error: one in my file and one in the moc file.

筅森魡賤 提交于 2019-12-22 04:47:18
问题 I have a class called FindAndReplaceBar, whose implementation is this: #include "FindAndReplaceBar.h" #include <QLabel> #include <QPushButton> #include <QGridLayout> #include <QTextDocument> #include <QLineEdit> FindAndReplaceBar::FindAndReplaceBar(QObject *parent) : QToolBar(NULL) { lblFind = new QLabel("Find: ",this); lblReplace = new QLabel("Replace",this); ledtFind = new QLineEdit(this); ledtReplace = new QLineEdit(this); QPixmap next(":/res/resources/next.gif"); QPixmap previous(":/res

CMake AUTOMOC with files on different folders

依然范特西╮ 提交于 2019-12-21 19:57:27
问题 I have a simple CMake project: proj (project folder) ├── a.h ├── a.cpp └── CMakeLists.txt CMakeLists.txt: cmake_minimum_required(VERSION 3.2) set(CMAKE_VERBOSE_MAKEFILE ON) set(CMAKE_AUTOMOC ON) project(proj) set( proj_SOURCE a.cpp ) find_package(Qt5Core) set( proj_LIBRARIES Qt5::Core ) add_library(proj SHARED ${proj_SOURCE}) target_link_libraries(proj ${proj_LIBRARIES}) a.h: #pragma once #include <QObject> class A : public QObject { Q_OBJECT public: explicit A(QObject *parent = 0); }; a.cpp:

Qt “signal undefined reference error” after inheriting from QObject

走远了吗. 提交于 2019-12-21 04:13:39
问题 I recently needed to add a signal to a class, so I changed the class to inherit from QObject and added the Q_OBJECT macro into the class definition. Since doing so I get "signal undefined reference error for 'vtable for CLICommand'" error on the class line below: // File clicommand.h #include <QString> #include <QStringList> #include <QTcpSocket> #include "telnetthread.h" class CLICommand : public QObject { Q_OBJECT public: CLICommand(TelnetThread *parentTelnetThread); signals: void signal

Macro expansion in moc

拟墨画扇 提交于 2019-12-18 08:24:57
问题 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,