Skip to content
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

缺少QPromise #2

Open
zyy890508 opened this issue Aug 11, 2023 · 2 comments
Open

缺少QPromise #2

zyy890508 opened this issue Aug 11, 2023 · 2 comments

Comments

@zyy890508
Copy link

编译发现缺少QPromise 找到QPromise之后再编译
QtEventBus-master\QtEventBus\qeventbus.cpp:4: error: qexport.h: No such file or directory
....\QtEventBus-master\QtEventBus\qeventbus.cpp:4:10: fatal error: qexport.h: No such file or directory
#include "qexport.h"
^~~~~~~~~~~

@weypro
Copy link

weypro commented Sep 18, 2023

这是该作者的另一个库,如果不想使用,可以删掉并手动改为简单的单例模式实现,例如:

QEventBus *QEventBus::globalInstance()
{
    if (instance == nullptr) {
        instance = new QEventBus();
    }
    return instance;
}

此外还需要再修改,我这边的原始错误是 error C2280: “PromiseResolver &PromiseResolver::operator =(const PromiseResolver &)”: 尝试引用已删除的函数
方案是将以下代码中的const删除:

template<typename R>
struct PromiseResolver {
    QtPromise::QPromiseResolve<R> const resolve;
    QtPromise::QPromiseReject<R> const reject;
};

原因:const或引用类型数据成员会导致编译器声明删除拷贝赋值运算符,参考https://learn.microsoft.com/zh-cn/cpp/error-messages/compiler-errors-1/compiler-error-c2280?view=msvc-170

@Fishoo0
Copy link
Collaborator

Fishoo0 commented Sep 18, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants