Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1099693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:46:16+00:00 2026-05-17T00:46:16+00:00

I’m writing a simple Qt4 application in Ruby (using qtruby ) to teach myself

  • 0

I’m writing a simple Qt4 application in Ruby (using qtruby) to teach myself both. Mostly it has gone well, but in trying to use Ruby’s “duck typing” I’ve run into a snag; respond_to? doesn’t seem to reflect reality.

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'Qt4'
=> true
irb(main):003:0> require 'qtuitools'
=> true
irb(main):004:0> Qt::Application.new(ARGV)
=> #<Qt::Application:0xc3c9a08 objectName="ruby">
irb(main):005:0> file = Qt::File.new("dlg.ui") { open(Qt::File::ReadOnly) }
=> #<Qt::File:0xc2e1748 objectName="">
irb(main):006:0> obj = Qt::UiLoader.new().load(file, nil)
=> #<Qt::Dialog:0xc2bf650 objectName="dlg", x=0, y=0, width=283, height=244>
irb(main):007:0> obj.respond_to?('children')
=> false
irb(main):008:0> obj.respond_to?(:children)
=> false
irb(main):009:0> obj.children
=> [#<Qt::FormInternal::TranslationWatcher:0xc2a1980 objectName="">, ... 

As you can see, when I check to ensure that the object I get back from loading the UI file has a children accessor I get false. If call that accessor, however, I get an array rather than a NoMethodError.

So, is this a bug or have I incorrectly understood respond_to??

This looks like the problem described here, but I thought I would get an expert opinion before filing a bug against the project.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:46:17+00:00Added an answer on May 17, 2026 at 12:46 am

    I just looked at the qtruby code which maps the Ruby code to QT and they use method_missing exclusively without implementing respond_to?. Thus it is exactly like the problem you linked to. I’ve worked around this a little by using obj.is_a?(Qt::Widget) (for example) which obviously isn’t duck typing but works well in some situations.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am writing an app with both english and french support. The app requests
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.