久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Qt moc 在頭文件中實現?

Qt moc with implementations inside of header files?(Qt moc 在頭文件中實現?)
本文介紹了Qt moc 在頭文件中實現?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

是否可以告訴 Qt MOC 我想聲明該類并在單個文件中實現它,而不是將它們拆分為 .h 和 .cpp 文件?

Is it possible to tell the Qt MOC that I would like to declare the class and implement it in a single file rather than splitting them up into an .h and .cpp file?

推薦答案

我相信這是最好的方法.這實際上是我現在構建所有對象的方式.

I believe this to be the best way. It's actually how I construct all of my objects now.

Qt 4.8.7

Works.pro:

SOURCES += 
    main.cpp

HEADERS += 
    Window.h 
    MyWidget.h

main.cpp

#include <QtGui>
#include "Window.h"

int main(int argc, char *argv[])
{
    QApplication app(argc,argv);

    Window window;
    window.show();
    return app.exec();
}

窗口.h

#ifndef WINDOW_H
#define WINDOW_H

#include <QtGui>
#include "MyWidget.h"

class Window : public QWidget
{
    Q_OBJECT

private:
    MyWidget *whatever;

public:
    Window()
    {
        QHBoxLayout *layout = new QHBoxLayout;
        setLayout(layout);

        whatever = new MyWidget("Screw You");
        layout->addWidget(whatever);

    }
};

#include "moc_Window.cpp"

#endif // WINDOW_H

MyWidget.h

#ifndef MYWIDGET_H
#define MYWIDGET_H

#include <QtGui>

class MyWidget : public QLabel
{
    Q_OBJECT

public:
    MyWidget(QString text) : QLabel(text)
    {
        // Whatever
    }
};

#include "moc_MyWidget.cpp"

#endif // MYWIDGET_H

構建...qmake Works.pro

Build... qmake Works.pro

制作

這篇關于Qt moc 在頭文件中實現?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 日韩成年人视频在线 | 一区二区播放 | 九九热最新地址 | 欧美激情综合五月色丁香小说 | 91丨九色丨国产在线 | 久久久久一区二区三区 | 国产激情一区二区三区 | 天天综合网天天综合 | 亚洲精品一区在线 | 美女视频一区二区 | 中文字幕成人av | 鲁大师一区影视 | 91精品国产乱码久久蜜臀 | www.蜜桃av| 91亚洲国产精品 | 久久精品一级 | 真人女人一级毛片免费播放 | 成人一区二区视频 | 最新免费av网站 | 午夜在线视频 | 久久久亚洲综合 | a在线视频 | 国产精品福利在线 | 欧美成人a | 三级视频网站 | 日本午夜免费福利视频 | 色黄网站 | 欧美精品在线一区二区三区 | 99色综合| 精品www| 最新中文字幕第一页视频 | 欧美日韩a | 亚洲欧美日本国产 | 成人免费视频网 | 国产国语精品 | 久久久久久久国产 | 欧美国产精品 | 精品欧美一区免费观看α√ | 国产 亚洲 网红 主播 | 伦理午夜电影免费观看 | 色资源在线 |