module Qt

/***************************************************************************

qtruby.rb  -  description

Constants

DesktopType
DialogType
DrawerType
Meta
PopupType
QObjectMember

An entry for each signal or slot Example

int foobar(QString,bool)
:name is 'foobar'
:full_name is 'foobar(QString,bool)'
:arg_types is 'QString,bool'
:reply_type is 'int'
SheetType
SplashScreenType
SubWindowType
ToolTipType
ToolType
WidgetType

These values are from the enum WindowType in qnamespace.h. Some of the names such as 'Qt::Dialog', clash with QtRuby class names. So add some constants here to use instead, renamed with an ending of 'Type'.

WindowType

Public Class Methods

debug_level() click to toggle source
# File lib/Qt/qtruby4.rb, line 43
def Qt.debug_level
  @@debug_level
end
debug_level=(level) click to toggle source
# File lib/Qt/qtruby4.rb, line 38
def Qt.debug_level=(level)
  @@debug_level = level
  Internal::setDebug Qt::QtDebugChannel::QTDB_ALL if level >= DebugLevel::Extensive
end
execute_in_main_thread(blocking = true, sleep_period = 0.001, delay_execution = false) { || ... } click to toggle source

Code which accesses the GUI must be executed in the main QT GUI thread. This method allows code in another thread to execute safely in the main GUI thread. By default it will block the main GUI thread until the code in the block completes althought this can be changed by passing false for the first parameter.

@param blocking [Boolean] Whether to block the main thread until the code

in the block finishing executing. If false the main thread will be
allowed to continue and the block code will execute in parallel.

@param sleep_period [Float] The amount of time to sleep between checking

whether the code in the block has finished executing

@param delay_execution [Boolean] Only used if called from the main GUI

thread. Allows the block to be executed in parallel with the main thread.
# File lib/Qt4.rb, line 101
def self.execute_in_main_thread (blocking = true, sleep_period = 0.001, delay_execution = false)
  if Thread.current != Thread.main
    complete = false
    RubyThreadFix.queue << lambda {|| yield; complete = true}
    if blocking
      until complete
        sleep(sleep_period)
      end
    end
  else
    if delay_execution
      RubyThreadFix.queue << lambda {|| yield; complete = true}
    else
      yield
    end
  end
end