I am in the process of creating a custom Python module. When the user clicks on a volume, a table is loaded and shown corresponding to that volume. The tables have many columns, and I would like to initialize this process so that the top of a table view is set (scrolled down) to a specific, predetermined row. For example, a user clicks on a volume, and it brings up a table view, but the top of the view is initialized to the 3rd row, rather than the first.
The module logic contains a table view: “self.tv = slicer.qmrmlTableView()”, and I would imagine this capability is available in one of its “set” functions, using something like
“self.tv.SETCURRENTROW(3)”
but I could not seem to find such a functionality. Any help on this issue would be greatly appreciated. Thank you!
In addition, is it possible to set the colors of a given cell? I saw there was a “setCellText” function for a table node, but I was not able to find a similar function for color. If any additional information/code would be helpful for this and the above please let me know! I would be happy to provide it. Thanks!
Thank you both for your responses! I am going to try the using the color node route if possible, and regardless of how I solve this, I will make sure to post my solution here.
I had a follow up for @lassoan
I wanted to clarify that what I am trying to do is change the background color of a specific cell, as opposed to the text color. I could not find the color node associated with my qMRMLTableView. I see that there are some “vtkColorTableNodes” in the subject hierarchy. However, when I went through the member functions of the qMRMLTableNode, I could not find anything that seemed like it would get the color node with which it is associated. What is the best way I can access/modify the color node that the qMRMLTableView displays? Thanks again!
I decided I would also try @pieper 's approach in the meantime. However, I’m not sure if I’m missing something. I posted my code below. Is there some signal I would have to send? I’m new to Qt. Thanks again–I really appreciate all your help!
% tv = my qMRMLTableView
model = tv.tableModel()
item = qt.QStandardItem()
brush = qt.QBrush()
brsh.setColor(qt.QColor(0,255,0))
item.setBackground(brush)
tv.tableModel().setItem(1,1, item)