【发布时间】:2016-06-16 08:44:41
【问题描述】:
我有一个数据读取器,它从缓冲区获取数据并将输出显示到控制台。现在我想将数据实时查看到文本编辑中。 我已经看到了一些示例,展示了如何从文本文件中读取数据(非实时)。
请查找附件。
/* Create a DataReader for the chatMessageTopic Topic (using the appropriate QoS). */
parentReader = chatSubscriber->create_datareader(
chatMessageTopic.in(),
DATAREADER_QOS_USE_TOPIC_QOS,
NULL,
STATUS_MASK_NONE);
checkHandle(parentReader.in(), "DDS::Subscriber::create_datareader");
/* Narrow the abstract parent into its typed representative. */
chatAdmin = Chat::ChatMessageDataReader::_narrow(parentReader.in());
checkHandle(chatAdmin.in(), "Chat::ChatMessageDataReader::_narrow");
/* Print a message that the MessageBoard has opened. */
cout << "MessageBoard has opened: send ChatMessages...." << endl << endl;
while (!terminated) {
/* Note: using read does not remove the samples from
unregistered instances from the DataReader. This means
that the DataRase would use more and more resources.
That's why we use take here instead. */
status = chatAdmin->take(
msgSeq,
infoSeq,
LENGTH_UNLIMITED,
ANY_SAMPLE_STATE,
ANY_VIEW_STATE,
ALIVE_INSTANCE_STATE );
checkStatus(status, "Chat::ChatMessageDataReader::take");
for (DDS::ULong i = 0; i < msgSeq->length(); i++) {
ChatMessage *msg = &(msgSeq[i]);
cout << msg->index << ": " << msg->content << endl;
fflush(stdout);
}
status = chatAdmin->return_loan(msgSeq, infoSeq);
checkStatus(status, "Chat::ChatMessageDataReader::return_loan");
【问题讨论】:
-
QtCreator 是一个 IDE。你正在使用 Qt!
-
提及您正在使用 RTI Connext C++ API 会有所帮助。
-
好吧,它是 Prismtech C++ 程序
标签: c++ linux qt user-interface