Closed maca89 closed 6 years ago
I think the problem is that you're trying to overload a basic operator in the C code with a Ruby method which obviously doesn't work. I think you'll just have to reimplement the TableWidget sort_items method to do what you want. I believe this method uses the TableView sortByColumn method to do the work. You might want to read up on how QT splits the Model and View code.
I see. I thought I already was overloading C++ methods with Ruby code, eg. when extending from Qt::AbstractItemDelegate
and overloading createEditor
method, isn't it actually kind of overloading C++ method? Which is called from deep inside of C++ Qt code? Or is this call handled somewhere manually in bindings layer?
In such case I see no problem in writing manual call of operator< where I would call the Ruby code. And otherwise – if it is overloading C++ code automatically – I see no problem in overloading operator as long as it's virtual. Because an operator is virtual method as any other, just with a funny name in the virtual table. But maybe it's just not possible for operators in Smoke or I got it all wrong. :-)
I don't think overloading operators is possible. sorry.
In Qt there is
QTableWidgetItem::operator<
method that is called byQTableWidget
when sorting items. Is there any way how to overload this method in Ruby? I am trying this with no luck.I tried to look into sources of qtbindings and qtruby, but it seems to me there is no operator overloading done anywhere. Apart from custom operators for Points etc. But the smoke itself seems to be somehow loading operator methods...
Maybe I could implement it and post a PR with some guidance. But is it even possible?