Class: Qt::Variant

Inherits:
Base show all
Defined in:
lib/Qt/qtruby4.rb

Direct Known Subclasses

DBusVariant

Constant Summary collapse

String =
Qt::Enum.new(10, "QVariant::Type")
Date =
Qt::Enum.new(14, "QVariant::Type")
Time =
Qt::Enum.new(15, "QVariant::Type")
DateTime =
Qt::Enum.new(16, "QVariant::Type")

Instance Method Summary collapse

Methods inherited from Base

#%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #QCOMPARE, #QEXPECT_FAIL, #QFAIL, #QSKIP, #QTEST, #QVERIFY, #QVERIFY2, #QWARN, #^, ancestors, #is_a?, #methods, private_slots, #protected_methods, #public_methods, q_classinfo, q_signal, q_slot, signals, #singleton_methods, slots, #|, #~

Constructor Details

#initialize(*args) ⇒ Variant

Returns a new instance of Variant



2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
# File 'lib/Qt/qtruby4.rb', line 2255

def initialize(*args)
  if args.size == 1 && args[0].nil?
    return super()
  elsif args.size == 1 && args[0].class.name == "Date"
    return super(Qt::Date.new(args[0]))
  elsif args.size == 1 && args[0].class.name == "DateTime"
    return super(Qt::DateTime.new(  Qt::Date.new(args[0].year, args[0].month, args[0].day),
                    Qt::Time.new(args[0].hour, args[0].min, args[0].sec) ) )
  elsif args.size == 1 && args[0].class.name == "Time"
    return super(Qt::Time.new(args[0]))
  elsif args.size == 1 && args[0].class.name == "BigDecimal"
    return super(args[0].to_f) # we have to make do with a float
  else
    return super(*args)
  end
end

Instance Method Details

#inspectObject



2380
2381
2382
2383
# File 'lib/Qt/qtruby4.rb', line 2380

def inspect
  str = super
  str.sub(/>$/, " typeName=%s>" % typeName)
end

#load(*args) ⇒ Object



2390
2391
2392
# File 'lib/Qt/qtruby4.rb', line 2390

def load(*args)
  method_missing(:load, *args)
end

#pretty_print(pp) ⇒ Object



2385
2386
2387
2388
# File 'lib/Qt/qtruby4.rb', line 2385

def pretty_print(pp)
  str = to_s
  pp.text str.sub(/>$/, " typeName=%s>" % typeName)
end

#to_aObject



2272
2273
2274
# File 'lib/Qt/qtruby4.rb', line 2272

def to_a
  return toStringList()
end

#to_fObject



2276
2277
2278
# File 'lib/Qt/qtruby4.rb', line 2276

def to_f
  return toDouble()
end

#to_iObject



2280
2281
2282
# File 'lib/Qt/qtruby4.rb', line 2280

def to_i
  return toInt()
end

#to_intObject



2284
2285
2286
# File 'lib/Qt/qtruby4.rb', line 2284

def to_int
  return toInt()
end

#type(*args) ⇒ Object



2394
2395
2396
# File 'lib/Qt/qtruby4.rb', line 2394

def type(*args)
  method_missing(:type, *args)
end

#valueObject



2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
# File 'lib/Qt/qtruby4.rb', line 2288

def value
  case type()
  when Qt::Variant::Invalid
    return nil
  when Qt::Variant::Bitmap
  when Qt::Variant::Bool
    return toBool
  when Qt::Variant::Brush
    return qVariantValue(Qt::Brush, self)
  when Qt::Variant::ByteArray
    return toByteArray
  when Qt::Variant::Char
    return qVariantValue(Qt::Char, self)
  when Qt::Variant::Color
    return qVariantValue(Qt::Color, self)
  when Qt::Variant::Cursor
    return qVariantValue(Qt::Cursor, self)
  when Qt::Variant::Date
    return toDate
  when Qt::Variant::DateTime
    return toDateTime
  when Qt::Variant::Double
    return toDouble
  when Qt::Variant::Font
    return qVariantValue(Qt::Font, self)
  when Qt::Variant::Icon
    return qVariantValue(Qt::Icon, self)
  when Qt::Variant::Image
    return qVariantValue(Qt::Image, self)
  when Qt::Variant::Int
    return toInt
  when Qt::Variant::KeySequence
    return qVariantValue(Qt::KeySequence, self)
  when Qt::Variant::Line
    return toLine
  when Qt::Variant::LineF
    return toLineF
  when Qt::Variant::List
    return toList
  when Qt::Variant::Locale
    return qVariantValue(Qt::Locale, self)
  when Qt::Variant::LongLong
    return toLongLong
  when Qt::Variant::Map
    return toMap
  when Qt::Variant::Palette
    return qVariantValue(Qt::Palette, self)
  when Qt::Variant::Pen
    return qVariantValue(Qt::Pen, self)
  when Qt::Variant::Pixmap
    return qVariantValue(Qt::Pixmap, self)
  when Qt::Variant::Point
    return toPoint
  when Qt::Variant::PointF
    return toPointF
  when Qt::Variant::Polygon
    return qVariantValue(Qt::Polygon, self)
  when Qt::Variant::Rect
    return toRect
  when Qt::Variant::RectF
    return toRectF
  when Qt::Variant::RegExp
    return toRegExp
  when Qt::Variant::Region
    return qVariantValue(Qt::Region, self)
  when Qt::Variant::Size
    return toSize
  when Qt::Variant::SizeF
    return toSizeF
  when Qt::Variant::SizePolicy
    return toSizePolicy
  when Qt::Variant::String
    return toString
  when Qt::Variant::StringList
    return toStringList
  when Qt::Variant::TextFormat
    return qVariantValue(Qt::TextFormat, self)
  when Qt::Variant::TextLength
    return qVariantValue(Qt::TextLength, self)
  when Qt::Variant::Time
    return toTime
  when Qt::Variant::UInt
    return toUInt
  when Qt::Variant::ULongLong
    return toULongLong
  when Qt::Variant::Url
    return toUrl
  end

  return qVariantValue(nil, self)
end