OSX上的QtRuby恢复了计时器上的最小化窗口(QtRuby on OSX restore minimized window on timer)

编程入门 行业动态 更新时间:2024-10-11 03:17:50
OSX上的QtRuby恢复了计时器上的最小化窗口(QtRuby on OSX restore minimized window on timer)

我正在OSX上使用QtRuby编写时间记录应用程序。 重要的是它定期提醒用户(我的团队)记录他们的时间,最好是到达前台(如果需要,最小化)。 这非常像mac,所以我会接受一个弹跳的任务托盘图标。 我无法上班。

无论如何,我尝试过以下几点

self.show() self.showNormal() self.raise() self.activateWindow() self.maximize() self.setWindowState(Qt::WindowActive) self.setWindowState(Qt::WindowMaximized) # Must execute this with GUI thread msgbox = Qt::MessageBox.new() msgbox.setText('LOG YOUR TIME!') msgbox.exec()

一旦最小化或在后台,所有这些命令似乎都被忽略。 在尝试弹出消息框时,我解决了“无法为不同线程中的父级创建子级”。 通过发出信号发生错误,但在用户激活窗口之前似乎没有处理事件。

有谁知道如何在OSX上弹出QTRuby甚至QT和C ++的最小化窗口?

TIA卢克

I'm writing a time logging application using QtRuby on OSX. It is important that it periodically reminds users (my team) to log their time, preferably by coming to the foreground (unminimizing, if necessary). This is very un-mac-like, so I would accept a bouncing task tray icon. I can't get either to work.

Anyway, I've tried the following

self.show() self.showNormal() self.raise() self.activateWindow() self.maximize() self.setWindowState(Qt::WindowActive) self.setWindowState(Qt::WindowMaximized) # Must execute this with GUI thread msgbox = Qt::MessageBox.new() msgbox.setText('LOG YOUR TIME!') msgbox.exec()

All these commands seem to be ignored once minimised or in the background. When trying to popup the messagebox, I worked around the "Cannot create children for a parent that is in a different thread." error by emitting a signal, but events don't seem to be processed until the user activates the window.

Does anyone know how to pop-up a minimised window with QTRuby or even QT & C++ on OSX?

TIA Luke

最满意答案

我使用Qt的线程而不是红宝石线程,现在一切都很可爱。 也许与全局解释器锁有关。

我换了

Thread.new { loop { every_minute_do_on_diff_thread; sleep 60 } } connect(self, SIGNAL('every_minute_do_signal()'), self, SLOT('every_minute_do()')) def every_minute_do_on_diff_thread emit(every_minute_do_signal()) end

timer = Qt::Timer.new(self); connect(timer, SIGNAL('timeout()'), self, SLOT('every_minute_do()')) timer.start(60000)

I used Qt's threads rather than ruby threads and everything is lovely now. Maybe be something to do with the global interpreter lock.

I replaced

Thread.new { loop { every_minute_do_on_diff_thread; sleep 60 } } connect(self, SIGNAL('every_minute_do_signal()'), self, SLOT('every_minute_do()')) def every_minute_do_on_diff_thread emit(every_minute_do_signal()) end

with

timer = Qt::Timer.new(self); connect(timer, SIGNAL('timeout()'), self, SLOT('every_minute_do()')) timer.start(60000)

更多推荐

本文发布于:2023-04-29 09:34:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335625.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:最小化   器上   窗口   QtRuby   OSX

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!