Question

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

Was it helpful?

Solution

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)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top