-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不支持Qt d_ptr类型的头文件编译 #750
Comments
给个复现的demo我看下 |
QT creator编译通过后提取的 target("test")
add_rules("qt.application")
set_kind("binary")
add_frameworks("QtCore","QtGui","QtWidgets")
add_includedirs("."
,"$(buildir)")
add_files("mainwindow.h")
add_files("mainwindow.cpp")
add_files("main.cpp")
target_end() mainwindow.h #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#if QT_VERSION >= 0x040400
QT_BEGIN_NAMESPACE
#endif
class MainWindowPrivate;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
MainWindowPrivate *d_ptr;
Q_DECLARE_PRIVATE(MainWindow)
Q_DISABLE_COPY(MainWindow)
Q_PRIVATE_SLOT(d_func(), void mainWindow_slot())
};
#if QT_VERSION >= 0x040400
QT_END_NAMESPACE
#endif
#endif // MAINWINDOW_H
mainwindow.cpp #include "mainwindow.h"
#include <qDebug>
class MainWindowPrivate
{
MainWindow *q_ptr;
Q_DECLARE_PUBLIC(MainWindow)
public:
MainWindowPrivate(){}
void mainWindow_slot(){qDebug()<<"mainWindow_slot";}
};
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
d_ptr = new MainWindowPrivate;
d_ptr->q_ptr = this;
}
MainWindow::~MainWindow()
{
}
#include "moc_mainwindow.cpp"
|
[ 33%]: compiling.debug mainwindow.cpp |
你发个完整的demo给我吧,我试下,最好qtcreater/xmake.lua的工程文件都带上。。 另外,建议用qt.widget_app/qt.quickapp rule,不要用qt.application rule,这个废弃了, |
追加-vD编译,给我看下完整错误信息 |
qt.widget_app我的xmake版本不能用 PS C:\Users\76441\Desktop\untitled> xmake -vD
stack traceback: stack traceback: |
demo在附件 qt.widget_app我的xmake版本没法使用
…------------------ 原始邮件 ------------------
发件人: "ruki"<notifications@github.com>;
发送时间: 2020年4月5日(星期天) 晚上11:59
收件人: "xmake-io/xmake"<xmake@noreply.github.com>;
抄送: "笨蛋,别回头"<76441660@qq.com>;"Author"<author@noreply.github.com>;
主题: Re: [xmake-io/xmake] 不支持Qt d_ptr类型的头文件编译 (#750)
你发个完整的demo给我吧,我试下,最好qtcreater/xmake.lua的工程文件都带上。。
另外,建议用qt.widget_app/qt.quickapp rule,不要用qt.application rule,这个废弃了,
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
github上没看到附件,为什么不能用?你用的是老版本xmake? |
附件已发到gmail中
|
收到 我回头看下,新版本为什么qt.widget_app不能用?报什么错? |
这我我之前说错了,应该是 qt.widgetapp 。。你再试试,肯定可以用的。。 至于你那个demo我看了,确实目前还不支持,这块比较蛋疼,qt对这这块处理有点那个,得分两种情况
|
是否可以通过头文件中的类内部的 Q_PRIVATE_SLOT来判断是否需要编译moc_xxx.cpp文件,QT中不需要编译moc_xxx.cpp是因为头文件出现了Q_PRIVATE_SLOT |
嗯 可以尝试下 |
我dev上处理过了,应该支持了,你更新下试试 xmake update dev 另外你的配置有点冗余了,只需要这样就行了: target("test")
add_rules("qt.widgetapp")
add_files("mainwindow.h")
add_files("*.cpp")
add_frameworks("QtCore", "QtGui") |
可以了么 |
可以了 |
但是 好像.cpp中如果有Q_OBJECT 宏 生成的文件似乎是xxx.moc ,一样要做Q_PRIVATE_SLOT处理!之前忘记说了, |
class MainWindowPrivate:public QObject
{
Q_OBJECT
public:
MainWindow *q_ptr;
Q_DECLARE_PUBLIC(MainWindow)
public:
MainWindowPrivate(){}
void mainWindow_slot(){qDebug()<<"mainWindow_slot";}
private:
Q_PRIVATE_SLOT(q_ptr, void test())
}; |
目前仅支持从.h生成moc,.cpp都会作为正常cpp代码来编译 |
有没有支持的计划,现在在做qt一些QtPropertyBrower开源库的xmake构建,跟QT源码大量的使用Q D指针模式,cpp不支持moc,这些工程都编译不了,只能自己修改cpp提取类 |
你给个 带qtcreator工程的demo 我先看下 |
我支持上了,不过需要对带有private slot的cpp文件,自己额外附带qt.moc规则。 target("test")
add_rules("qt.widgetapp")
add_files("main.cpp")
add_files("mainwindow.cpp", {rules = "qt.moc"}) <---- 此处
add_files("*.h")
add_files("*.ui") 因为cpp有自己内置的构建规则,不能全局改这块,只能通过用户手动指定作为moc规则来处理,而.h因为专属只对qt rule生效,所以内部自动加了qt.moc,不指定也没关系 你更新下dev试试 |
好的 |
这个可以了么 |
可以了 感谢 |
如果头文件出现类似
QtTreePropertyBrowserPrivate *d_ptr;
Q_DECLARE_PRIVATE(QtTreePropertyBrowser)
Q_DISABLE_COPY(QtTreePropertyBrowser)
将无法编译通过,因为QtTreePropertyBrowserPrivate定义 在QtTreePropertyBrowser.cpp内
The text was updated successfully, but these errors were encountered: