我正在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()) endwith
timer = Qt::Timer.new(self); connect(timer, SIGNAL('timeout()'), self, SLOT('every_minute_do()')) timer.start(60000)更多推荐
发布评论