问题标签 [qevent]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
275 浏览

pyqt - pyqt 鼠标按住事件过滤器

我是 PyQt 的新手,我想不通。我正在尝试安装一个 eventFilter,以便当按下并按住 QPushButton 时,系统会以一定的速率递增一个值(这可能是一个 QTimer)。我在同一页面上有第二个 QPushButton,当它被按下并按住时,应该减少值。系统需要区分单击和按住。这是我到目前为止所拥有的,这还不错,但我相信有一种更有效的方法可以做到这一点。

0 投票
1 回答
590 浏览

qt - 尝试使用 QMouseEvent

我对 QMouseEvent 有疑问:

我创建了一个场景,并在场景中插入了一些 QGraphicsPixmapItem。现在我想在单击指定的 QGraphicsPixmapItem 时输入“if”。

例如,当我单击 img_manoG1 时,我想输入第一个“if”

如何告诉程序停止并等待鼠标输入?

TI 是 Qt 的新手,这是我第一次使用这些对象,所以我犯了很多逻辑错误,所以使用 QStateMachine 这是一个大问题......

这是唯一的方法吗?我试着解释我的程序:

我想创建一个纸牌游戏,在以前的版本中,我使用了一个带有以下命令序列的旧图形库:

这样我告诉程序:

现在我想改变程序图形,我已经介绍了 QGraphics。我创建了一个场景并在其上打印所有对象“卡片”,所以现在我想告诉程序:

问题是我使用for1 到 20(我必须在一场比赛中跑 20 次)。我尝试使用随机的 G1 和 COM 播放来启动程序,但应用程序冻结到最后一次执行,for并且我在场景上仅打印卡的最后配置。这就是原因,因为之前我说过我希望程序停止......

没有 QStateMachine 可以吗?简单地告诉他:“暂停”,打印这种情况,等待鼠标继续?

0 投票
2 回答
371 浏览

c++ - QStateMachine - QMouseEvent

在另一个问题中,您告诉我使用 QStateMachine。

我是 Qt 新手,这是我第一次使用这些对象,所以我犯了很多逻辑错误,所以使用 QStateMachine 这是一个大问题......

这是唯一的方法吗?我试着解释我的程序:

我想创建一个纸牌游戏,在以前的版本中,我使用了一个带有以下命令序列的旧图形库:

这样我告诉程序:

现在我想改变程序图形,我已经介绍了 QGraphics。我创建了一个场景并在其上打印所有对象“卡片”,所以现在我想告诉程序:

问题是我使用for1 到 20(我必须在一场比赛中跑 20 次)。我尝试使用随机的 G1 和 COM 播放来启动程序,但应用程序冻结到最后一次执行,for并且我在场景上仅打印卡的最后配置。这就是原因,因为之前我说过我希望程序停止......

没有 QStateMachine 可以吗?简单地告诉他:“暂停”,打印这种情况,等待鼠标继续?

0 投票
1 回答
349 浏览

c++ - Qt:从 QGraphicsView 传递 QGraphicsSceneContextMenuEvent

我从 QGraphicsView 和 QGraphicsRectItem 派生。我在两个类上重载了 contextMenuEvent 以提供弹出菜单。当你点击一个项目时,我想要 QGraphicsView 上下文菜单,当你点击空白时 QGraphicsItem 弹出菜单。

在第一次实现时,无论我点击哪里,我都会得到 QGraphicsView 弹出窗口。所以我修改了 contextMenuEvent 如下:

QGraphicsSceneContextMenuEvent 的 dynamic_cast 失败,所以我从不为 rect 调用 contextMenuEvent。如果我只是尝试将事件传递给 rect->contextMenu(),它将无法编译,所以我尝试了强制转换。

这样做的正确方法是什么?

这是一个使用 Qt 创建/移动/旋转/删除 2D 形状的学习项目。如果有人想看整个事情,请告诉我。

0 投票
1 回答
20121 浏览

c++ - "QPainter::drawRects: Painter not active " error C++/QT

I'm a beginner at Qt and c++ and I wanted to see how to use a QPainter and events in Qt but I got stuck because of an error message during the execution, my original code:

the main.cpp

and the header:

and the .cpp:

I tried to search it on the web and saw that it's because the QPainter isn't located in the paintEvent but it's not the case in my code, thanks for your help.

0 投票
1 回答
1129 浏览

c++ - 如何在 Qt 中处理所有子小部件的按键事件?

我想处理所有子小部件的按键事件,为此我正在尝试如下操作:

但是,无论我按什么F1,都只会somesignal()发出。我想发出somesignal1(),somesignal2()也, forbutton1button2.

有人可以帮助我实现这一目标吗?

0 投票
0 回答
560 浏览

wkhtmltopdf - QEventDispatcher:创建 QEventDispatcherWin32 内部窗口失败:1407

我们有一个 web 应用程序,它在自己的进程中运行 wkhtmltopdf.exe 以将 html 字符串转换为 pdf 文件。

在实时服务器上,它无法完成,并且当进程被终止时报告错误:

相同的代码在 cmd 行和另一台支持服务器上运行正常。

0 投票
1 回答
536 浏览

qt - 我可以延迟/捆绑对 QPlainTextEditor.textChanged 事件的反应吗?

我有一个用于我编写的建模语言的小型 IDE,在 PyQt/PySide 中实现,并且正在尝试实现一个代码导航器,让您可以跳转到正在编辑的文件中的不同部分。

当前的实现是:(1)连接到 QPlainTextEditor.textChanged,(2)任何时候进行更改,(草率地)解析文件并更新导航器窗格

它似乎工作正常,但我担心这可能会导致较慢系统上的大文件出现重大性能问题,特别是如果将来有更多内容连接到 textChanged。

我的问题:这里有没有人实现了对事件的延迟反应,以便在短时间内多个事件(即击键)只触发一次更新(比如每秒一次)?有没有合适的 QT 方式来做到这一点?

谢谢,迈克尔

0 投票
1 回答
711 浏览

qt - QWebEngineView, post KeyEvents inside the View

I have my own "Virtual Keyboard". I already got to transform buttons clicked into KeyEvents and deliver it to QTextEdit and so on. My problem now is that I want to do the same for writable areas inside a QWebEngineView.

For example, I use my keyboard to edit my QLineEdit, and request a website. DONE

Let's say I requested google. Now I have the Google website right in front of me. I need to send KeyEvents from my Keyboard to it's search box.(Box that is inside my QWebEngineView.

Let's now point a few points:

  1. I am using PyQt5
  2. As I've read, the API says me that it's parent should consume the KeyEvent to the corect place. here
  3. This snippet says "...like it was possible with QtWebKit."
  4. I've seen now that there is no more QtWebKit, and so Chromium instead.(Maybe that's the reason I'm not getting to post these events)

This is what I have for example to simulate KeyEvents to my QEditText and whatever..

This Last part is the one that I post my events on the "self.__receiver". This receiver is set always for the "QWidget" that invoke it.

I have tried just to say something like:

0 投票
1 回答
704 浏览

qt - 在发生之前拦截小部件移动/调整大小

我正在使用QMdiSubWindow,我想捕获任何试图修改窗口大小/形状/位置的输入,并过滤/修改结果位置和大小,以便小部件与网格对齐。

QResizeEvent似乎为时已晚,即窗口已经调整大小,布局已经计算出来,并且通常已经安排了小部件的完整重绘。

resizeEvent并且eventFilter两者都只允许我了解刚刚发生的调整大小并在不希望更改时“撤消”它,这对我来说是一个巨大的性能问题(嵌入式设备,缓慢的图形)。

我目前正在捕捉QMouseEvents 并修改报告的光标位置,但这很混乱,并没有捕捉到窗口几何形状发生变化的所有情况。