Summary: | qtruby can't be used with QML, return type of QAbstractItemModel::roleNames is unrecognized | ||
---|---|---|---|
Product: | [Developer tools] bindings | Reporter: | Florian Staudacher <florian_staudacher> |
Component: | general | Assignee: | kde-bindings |
Status: | RESOLVED WORKSFORME | ||
Severity: | major | CC: | cpigat242 |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: |
add handlers for role name methods
sorry, wrong file |
Description
Florian Staudacher
2012-08-20 21:00:25 UTC
Created attachment 82394 [details]
add handlers for role name methods
here is a patch that fixes that problem for me (not sure if the code should be ifdefed to a minimum version of Qt)...
with this models written in ruby can have role names set.
# example: subclassing a QListModel
class TestModel < Qt::ListModel
def initialize
super
set_role_names({ 1000 => "user_role", 1001 => "another_role"})
end
def rowCount(parent)
x
end
# yes, it's a list, but for some reason it needs this method
# to be implemented. just humor me here...
def columnCount(parent)
1
end
def data(idx, role)
return Qt::Variant.new("something") if role == 1000
return Qt::Variant.new("otherthing") if role == 1001
end
end
and then it can be attached the model to the root context of a QDeclarativeView.
this allows it to be used via qml like any other C++ model.
@model = TestModel.new
@qmlview = Qt::DeclarativeView.new
@ctx = @qmlview.root_context
@ctx.set_context_property("test_model", @model)
Created attachment 82395 [details]
sorry, wrong file
Thank you for reporting this bug in KDE software. As it has been a while since this issue was reported, can we please ask you to see if you can reproduce the issue with a recent software version? If you can reproduce the issue, please change the status to "CONFIRMED" when replying. Thank you! Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone! This bug has been in NEEDSINFO status with no change for at least 30 days. The bug is now closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging Thank you for helping us make KDE software even better for everyone! |