qobject

How do I copy object in Qt?

吃可爱长大的小学妹 提交于 2019-12-17 06:51:11
问题 I'm using Qt and have some real basic problems. I have created my own widget MyTest that have a variable obj . I need to set this variable obj from an object outside of the widget so that the variable is copied not just a pointer to another object. I get an error message and can't figure out how to do this basic stuff. This is the code I'm using: MyTest.h: class MyTest : public QWidget { Q_OBJECT public: void setObj(QObject &inobj); QObject obj; .... } MyTest.cpp: void MyTest::setObj(QObject

When should Q_OBJECT be used?

我怕爱的太早我们不能终老 提交于 2019-12-17 05:01:00
问题 The documentation states that: The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt's meta-object system. But exactly what does that mean? On which QObject-derived classes can I safely omit it? Will problems arise if you omit Q_OBJECT on a QObject-derived class, and then inherit from that one? Basically I would like a little more information on when I can omit it from my Qt classes. 回答1:

When should Q_OBJECT be used?

為{幸葍}努か 提交于 2019-12-17 05:00:20
问题 The documentation states that: The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt's meta-object system. But exactly what does that mean? On which QObject-derived classes can I safely omit it? Will problems arise if you omit Q_OBJECT on a QObject-derived class, and then inherit from that one? Basically I would like a little more information on when I can omit it from my Qt classes. 回答1:

QObject cloning

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-14 01:01:03
问题 I know that Qobjects are supposed to be identities not values eg you cannot copy them and by default the copy constructor and assignment are disabled as explained in qt documentation. But is it possible to create a new QObject from an existing one using a clone method? Would this be a logic error ? If I say QObject b; QObject a; b.cloneFrom(a); or QObject a = new QOBject(); QObject b = new QOBject(); b->cloneFrom(a); and the clone method copies stuff like members etc would this be wrong? And

Qt-fy existing enum to use with Qt metadata

送分小仙女□ 提交于 2019-12-13 14:41:09
问题 Let's assume I have an existing enum X { A, B } and want to use it with Qt metadata such as QMetaObject / QMetaEnum . QMetaObject meta = FsxSimConnectQtfier::staticMetaObject; for (int i=0; i < meta.enumeratorCount(); ++i) { QMetaEnum m = meta.enumerator(i); } If I define my enum within a Q_OBJECT class, all is fine, i.e. I can retrieve MyEnum by the metadata system. But how can I make X available for the metadata system? class FsxSimConnectQtfier : public QObject { Q_OBJECT Q_ENUMS(MyEnum) Q

How to import and use QObject in a BB10 Cocos2D based app

流过昼夜 提交于 2019-12-13 05:22:11
问题 I am currently working on building a Cocos2d-x game for the BB10 platform using the BBTemplateProject sample provided with Cocos2dx. I am new to C++ programming, and the current game is a port of a java project Iv been working on for a while. In order to save game data (scores, some settings etc), I intend to use the QtSQl Library which BB10 provides. I have successfully run some sample Qtsql code in a sample Cascades application and it works fine. However, integrating the same code into my

Showing the same QPushButton on multiple widgets

对着背影说爱祢 提交于 2019-12-12 08:58:52
问题 I have two widgets (Real and Fake) and one of them has a QPushButton. Now I want the same button to be shown in the other widget. How do I do it? I dont want to create a copy, I want the same QObject on to be shown another widget at the same time without changing the parent. As an example, in the following I want "mybutton" to be shown in both the widgets at the same time; QWidget *widgetReal = new QWidget(); QWidget *widgetFake = new QWidget(); widgetReal->setWindowTitle("Real"); widgetFake-

Mainpulating a QObject created from a button press

好久不见. 提交于 2019-12-12 03:52:54
问题 I am making an application, and at some point, the user will be creating some sort of from/survey. When creating, the user selects the various question types etc. by pressing a button and a new object will be created. To create a new section, for example: void CreateSurvey::question_section() { QLabel *sectionTitle = new QLabel(); sectionTitle->setText("New Section"); layout->addWidget(sectionTitle); QLabel *titleLabel = new QLabel("Title"); QLineEdit *titleEdit = new QLineEdit("New Section")

Connect: No such Slot QTreeView

时间秒杀一切 提交于 2019-12-11 13:33:56
问题 I have inherited a class MainTree from QTreeview maintree.cpp file void MainTree::LaunchTree() { //Tree launching connect(this, SIGNAL(customContextMenuRequested(const QPoint& )),this,SLOT(showCustomContextMenu(const QPoint&))); } void MainTree::showCustomContextMenu(const QPoint &pos) { //Add actions } But i get the following error QObject::connect: No such slot QTreeView::showCustomContextMenu(const QPoint&) I could not understand why, am i missing something ?? Definition of the class

Q_OBJECT Problem in Visual C++

风格不统一 提交于 2019-12-11 10:57:58
问题 I have received a Visual C++ QT based project from our customer. I have installed QT libraries then I have compiled the project. The Project was compiled without any problems. Now, I need to include a new additional GUI interface with the existing project. I have created a GUI in QT designer then saved in the source directory of VC++ project. Then I have written .h and .cpp file for new GUI and could call this interface. Now I need to include SIGNALS and SLOTS, when I include Q_OBJECT in .h