- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
目前正在研究 SBC (Olimex A20) 的 GPIO,我遇到了 QSocketNotifier 的问题。在我的 GPIO 上,我使用了一个具有中断功能的引脚(对于那些想了解更多信息的人:https://developer.ridgerun.com/wiki/index.php/How_to_use_GPIO_signals) 和一个 QSocketNotifier 来监控变化。
这是我的打扰类(class):
OLinuXinoGPIOEdge::OLinuXinoGPIOEdge(int num)
: m_gpioNumber(num), m_value(false), m_direction(IN)
{
this->exportGPIO(); // equivalent to 'echo num > export'
this->setDirection(IN); // for security
m_fileValue.setFileName("/sys/class/gpio/gpio20_pi11"); // the path of the pin
this->setEdge(BOTH); // edge's detection (both/falling/rising/none)
m_timer = new QTimer();
m_timer->setInterval(10);
m_timer->setSingleShot(true);
m_fileValue.open(QFile::ReadOnly);
m_fileNotifier = new QSocketNotifier(m_fileValue.handle(), QSocketNotifier::Exception); // Actually, emits the signal whenever an interruption is raised or not
connect(m_fileNotifier, SIGNAL(activated(int)), m_timer, SLOT(start()));
connect(m_timer, SIGNAL(timeout()), this, SLOT(changeNotifier()));
}
我已经问了一个问题(在这里:https://stackoverflow.com/questions/23955609/qtimer-and-qsocketnotifier)但是问题变了,所以我在这里再问一次。
为什么 QSocketNotifier 不断发出信号?在 GPIO 的目录中,可以修改文件“edge”以在下降沿、上升沿、两个边沿或无边沿产生中断,这意味着只应在该边沿产生中断。
最佳答案
好的,我有我的解决方案:QSocketNotifier 不断发出信号,直到您对文件使用“readAll()”函数。所以需要尽快调用readAll()来阻止QSocketNotifier的垃圾邮件。
关于c++ - QSocketNotifier 和 QFile::readAll(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23989477/
在我的一个方法中,我需要一个 QFile 对象: void GUIsubclassKuehniGUI::LoadDirectory() { QString load
我需要将一个 QFile 成 block 地复制到另一个 QFile,所以我不能使用 QFile::copy。这是最原始的实现: bool CFile::copyChunk(int64_t chunk
我正在我的类中实现一个方法,它将数据从 TableView 对象写出到 CSV 文件。然而,当程序运行时,程序以非常慢的速度(3 或 4 秒)将数据写入 USB 驱动器上的文件,但在系统的内部驱动器上
我不知道为什么,但我无法让最简单的 QTemporaryFile 示例运行...我的真正意图是在稍后处理之前将来自 QAudioInput 的数据写入临时文件。 尝试了几次后,我意识到 .read()
我想知道如何 QFile当多个句柄打开到同一个文件时(在 Windows 7 上的 Visual Studio 2013 中使用 C++),我编写了以下小程序: QFile file("tmp.t
当我定义如下结构时出现问题 struct TInputData { QString filename; QFile file; QTextStream
我有一个类(class): Class MyClass { void myMember(); ///code etc private: QFile fileMB
我需要编写一个控制台应用程序来接收一个文件,打开它,然后根据文本文件中的信息调用另一个过程。唯一的问题是 QFile::errorString() 返回: No such file or direct
我编写了以下代码来从文件中检索数据(该文件已经存在并且因为我在 Windows 操作系统上而获得了权限),并创建了项目以在列表中显示数据片段,但该列表不会显示任何内容事物。此外,我发现即使未创建文件,
我有一个名为“sequence_30.dat”的文件,其中包含垂直表示中的 1 和 -1 序列(即:每个 1 或 -1 在单独的行中)..我正在尝试读取文件以获取使用以下代码的另一个操作: int l
是否可以做到以下几点? QFile file("Test.txt") If (file.exists) { //Start writing new data at th
从文件中读取数据并将其保存在 QHash 中,如下所示: QHash > 我的数据文件不包含标题,所以当我第一次创建 vector 然后进入文件循环时,我错过了第一行的数据。我的来源是: Q
我有几个窗口标志为 WindowStaysonTopHint 的对话框。当我打开 QFileDialog 时,它显示在这些对话框的底部。如何为 QFileDialog 设置窗口标志。我使用以下代码在顶
我有一个基本上是从 Qt 网站上窃取的程序,用于尝试打开一个文件。该程序拒绝打开任何我不明白为什么的东西。我已经查找了很多文档,但一无所获,请您解释一下为什么它不起作用。 #include "main
QLabel* codeLabel = new Qlabel; QFile file("C:\index.txt"); file.open(stderr, QIODevice::WriteOnly);
我可以第二次初始化一个QFile并赋值吗?我这样试过 ... QFile file; ... if (i == 0) file = QFile("foo.txt"); else file = QFil
我在 generateCSVHeader(*file4); 处遇到非法间接错误。 函数声明: void generateCSVHeader(QFile * file); 功能使用: str="MyDa
我想知道是否可以一次性创建文件及其目录。例如我想创建文件scripts/myFile.txt。 我写了这样的代码: QFile _file( path ); QDir _dir; // check i
例如: QFile f("/home/umanga/Desktop/image.jpg"); 如何仅获取文件名 - “image.jpg”? 最佳答案 使用 QFileInfo删除路径(如果有): Q
造成这种情况的一些常见原因是什么?我的第一个想法是我正在读取的文件是只读的,但我已经检查过了。 调用它的代码是: QFile histogramFile(fileName); quint64 file
我是一名优秀的程序员,十分优秀!