0
我下面的例子遍佈包括該SO回答:https://stackoverflow.com/a/14114878/274354創建圖像的Qt和紅寶石的列表:引發ArgumentError
我的代碼跌倒在試圖與該消息的圖標創建ListWidgetItem時:
/usr/lib64/ruby/site_ruby/1.9.1/Qt/qtruby4.rb:2642:in `initialize': unresolved constructor call Qt::ListWidgetItem (ArgumentError)
下面是代碼:
require 'Qt4'
app = Qt::Application.new(ARGV)
# Main Window
widget = Qt::Widget.new()
# Create icon from a file, and create a list widget item from the icon
icon = Qt::Icon.new("/home/user1/Pictures/testimage.JPG")
item = Qt::ListWidgetItem.new(icon) #<-- Falls over here
# Create a list widget
list = Qt::ListWidget.new(widget)
# Set the icon size for the list
iconsize = Qt::Size(40,40)
list.setIconSize(iconsize)
# Add the list item with the image
list.addItem(item)
widget.show()
app.exec()
您的回答讓我再次查看代碼,並且在Icon旁邊,它期望一個字符串。謝謝。 – mydoghasworms