小编Man*_*d3r的帖子

ZeroMQ是否允许多个服务器套接字?

本机C套接字API在accept()新的套接字描述符上返回,该描述符绑定到某个远程套接字.这很好,因为我可以通过互联网创建一个线程,传递套接字并建立一个点对点,或者更好的线程到线程连接.而这正是我想要的:来自客户端的一个线程应该连接到服务器上的目标线程.因此,我不需要工作池或负载平衡甚至不同步操作.服务器线程保存历史记录.ZeroMQ似乎很棒,但据我所知,它不会在接受时拆分套接字.

有没有办法与ZerMQ建立这样的同步线程到线程连接?

c++ networking zeromq

4
推荐指数
1
解决办法
216
查看次数

是否有libXrandr API文档?

我想在C++中使用libXrandr.有合适的文件吗?

c++ linux x11 xrandr

4
推荐指数
1
解决办法
2420
查看次数

SVG图标不会出现在Qt5中

我在ressource文件中使用我的应用程序中的SVG图标,但是当我运行应用程序时,图标不会显示.以相同的方式使用jpg图标非常好.

c++ qt svg qt5

4
推荐指数
1
解决办法
3627
查看次数

在Qt5中,Q_INVOKABLE是否需要从QML调用公共QObject函数?

我刚刚意识到我几乎可以调用暴露给QML的对象的任何函数.现在我对Q_INVOKABLE感到好奇.Qt5 文档声明:

[...]任何QML代码都可以访问QObject派生类的实例的以下成员:

  • 属性

  • 方法(提供它们是公共插槽或标记为Q_INVOKABLE)

  • 信号

从Qt5(在C++中)开始,我可以像插槽一样调用QObject的任何公共函数,即我不必将它们声明为"公共插槽".这是否意味着我可以从QML调用任何方法?我无法在文档中找到任何内容.

c++ qt qml qt5

4
推荐指数
1
解决办法
1234
查看次数

纯虚方法采用各种迭代器?

让多态基类insert在 stl 容器成员(本例中为向量)上有一个纯虚方法。该函数应该能够采用集合、向量、列表等容器的迭代器,但也要考虑引用的类型(移动语义)

\n

函数的纯虚拟性质使得使用模板函数变得不可能。据我所知,stl 容器的迭代器是单独的类型,这就是模板有用的原因。然而,多态性是必要的。我还注意到 std::move_iterator 能够封装所有类型的迭代器。

\n

是否还有其他“迭代器包装器”,我可以用它来在 Base 中定义纯虚拟方法,该方法接受各种迭代器,并且也像完美转发函数模板一样,以便客户端可以传递迭代器并移动迭代器?

\n

在引入多态性之前,函数是这样的:

\n
vector<Class> v;\ntemplate<typename Iter>\nvoid insert(Iter begin, Iter end) {\n    v1.insert(begin, end, std::end(v));\n}\n
Run Code Online (Sandbox Code Playgroud)\n

但现在派生类在插入时的行为略有不同(互斥体、通知观察者等)。如果有类似下面的东西那就太好了:

\n
vector<Class> v;\n\nvirtual void Base::insert(GenericIter begin, GenericIter end) = 0;\n\n[\xe2\x80\xa6]\n\nvoid DerivedMT::insert(GenericIter begin, GenericIter end) override\n{\n    mutex.lock();\n    v1.insert(begin, end, std::end(v));\n    mutex.unlock();\n}\n\n[\xe2\x80\xa6]\n\nvoid DerivedObserved::insert(GenericIter begin, GenericIter end) override\n{\n    v1.insert(begin, end, std::end(v));\n    notifyObservers();\n}\n
Run Code Online (Sandbox Code Playgroud)\n

c++

4
推荐指数
1
解决办法
169
查看次数

Boost :: asio不在Debian Wheezy上?

Boost :: asio自1.35版开始包含在Boost中.但是我无法在Debian Wheezy的boost库中找到asio,尽管它的版本是1.48.他们不受支持吗?

c++ debian boost

3
推荐指数
1
解决办法
2718
查看次数

Vim鼠标滚轮垂直滚动只需一行

如何调整我的vimrc以使垂直滚动更平滑?我想实现鼠标滚轮的一次迭代只滚动一行而不是三行.

vim mouse

3
推荐指数
2
解决办法
1332
查看次数

如何以稳定的方式进行部分排序

std::partial_sort稳定的,如果没有,是否有标准库提供的稳定局部排序或例如boost?

c++ sorting

3
推荐指数
1
解决办法
943
查看次数

如何使用 CMake 项目调试 QML

我已经设置了标志 -DQT_QML_DEBUG 并在“构建并运行 > 运行 > 调试器设置”(我的翻译)中选中了“启用 QML”,但我仍然无法使用调试器。指令指针根本不显示,文本视图不跟随指令指针。另外,我在启动时收到此警告:

Warning: "QML Debugger: Invalid argument 'services:DebugMessages' detected. Ignoring the same."
Warning: "QML Debugger: Invalid argument 'QmlDebugger' detected. Ignoring the same."
Warning: "QML Debugger: Invalid argument 'V8Debugger' detected. Ignoring the same."
Warning: "QML Debugger: Invalid argument 'QmlInspector' detected. Ignoring the same."
QML Debugger: Waiting for connection on port 39750...
Run Code Online (Sandbox Code Playgroud)

编辑:环境是 archlinux,因此是最新版本。

c++ debugging qt cmake qml

3
推荐指数
1
解决办法
4435
查看次数

QProcess 在没有 waitForFinished() 时不发出信号

在下面的代码中,省略waitForFinished()使 QProcess 停止发出它的信号。它到底有什么问题?这是一个Qt错误吗?(5.7)。请注意,此代码与 QtConcurrent 并行运行。但这不应该改变任何事情,不是吗?Afaik 在其他线程中发送信号很好,尽管它们会排队。

QProcess *process = new QProcess;
process->setReadChannel(QProcess::StandardOutput);

connect(process, &QProcess::readyReadStandardOutput, [](){
    qDebug()<< "readyReadStandardOutput";
});

connect(process, &QProcess::stateChanged, [](QProcess::ProcessState state){
    qDebug()<< "stateChanged"<< state;
});

connect(process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
    [=](){
    qDebug()<< "finsished";
});

connect(process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
    [this, process](int exitCode, QProcess::ExitStatus exitStatus){
    qDebug()<< "finsished";
    if (exitStatus == QProcess::NormalExit && exitCode == 0){
        while (process->canReadLine()) {
           QString line = QString::fromLocal8Bit(process->readLine());
           QRegularExpression regex("\"(.*)\" {(.*)}");
           QRegularExpressionMatch match = regex.match(line);
           names_.push_back(match.captured(1));
           uuids_.push_back(match.captured(2));
        }
    }
    process->deleteLater();
});
process->start("VBoxManage",  {"list", "vms"});
process->waitForFinished(); // This line …
Run Code Online (Sandbox Code Playgroud)

c++ qt

3
推荐指数
1
解决办法
2406
查看次数

标签 统计

c++ ×9

qt ×4

qml ×2

qt5 ×2

boost ×1

cmake ×1

debian ×1

debugging ×1

linux ×1

mouse ×1

networking ×1

sorting ×1

svg ×1

vim ×1

x11 ×1

xrandr ×1

zeromq ×1