2

I'm using QtRuby + Mysql2 in a project, and i'm trying to retrieve all the data I need to populate the form.

First, a query is made. Then, each value is taken and used to fill each related widget.

client = Mysql2::Client.new(:host => "localhost", :username => "root", :password => "", :database => "school")
res= client.query("SELECT * FROM activ WHERE act_name = '#{@cActiv.currentText()}' ")
res.each do |row|
            @tName.setText(row['act_name'].to_s)
            @tType.setText(row['act_type'].to_s)
            @strDate= row['act_date'].to_s
            @year=@strDate[0,4].to_i
            @month=@strDate[5,2].to_i
            @day=@strDate[7,2].to_i
            @date= Qt::Date.new(@year, @month, @day)
            @deDate.setDate(@date)
end

The Problem is that I've got an error when trying to set the date to the DateEdit, even when the QDate object was created with no error.

Any thoughts?

Juank
  • 155
  • 3
  • 13
  • I don't know ruby, but I think that it can be very helpful to others if you tell us which error you get. – Jablonski Sep 14 '14 at 17:37
  • Sorry. It's "undefined method 'setDate' for QtDateEdit". setDate needs a Qt::Date as argument, and a Qt::Date needs three integers as arguments, so that's when I get lost and don't see where is the error in the code above. One more thing: printing the value of @date before the setDate, throws this: # ; so I guess it's a Qt::Date after all, but just cannot use it for setting the date of the QtDateEdit (really confusing) – Juank Sep 15 '14 at 01:03

1 Answers1

0

The problem is not within the shown code fragment. Either @year, @month, or @day do not receive valid values from the string conversions, or @deDate is not a Qt::DateEdit.

bogl
  • 1,864
  • 1
  • 15
  • 32