Let me clarify one thing. When I said QVBoxLayout.whatever, I am obviously 
referring to your own vertical layout in the tab that will contain all the 
LightItems

On Oct 8, 2012, at 10:43 PM, Justin Israel wrote:

> Here is what I would suggest..
> 
> Create your splitter widget as a custom widget; lets call it LightItem
> Install the LightItem as the event filter for the QLineEdit. You would do 
> that in your LightItem class with self.theLineEdit.installEventFilter(self)
> Create the eventFilter() method (see QObject), and have it watch for a 
> KeyPress on the QLineEdit. If it is key UP or key DOWN, emit a custom signal. 
> Lets call it moveItemRequested(int) , where int is either Qt.Key_Up or 
> Qt.Key_Down. 
> You can either also have that signal send the reference to the LightItem 
> widget, or, refer to self.sender() in the receiving slot later.
> Now your custom LightItem emits a custom signal for a key up or down
> When you loop over the lights (for i in lightTransforms)...
> Create a new LightItem for that light
> connect the LightItem.moveItemRequested() to a slot that will handle any item 
> moves. Lets call it moveLightItem(direction).
> moveLightItem(direction) will receive either Qt.Key_Up or Qt.Key_Down. And if 
> you also passed the reference to the LightItem object emitting the signal, 
> you will have that. Or you can check it with self.sender()
> Get the current index of the widget with QVBoxLayout.indexOf(theLightItem)
> If the key was UP, move the LightItem with 
> QVBoxLayout.insertWidget(max(cur_index-1, 0), theLightItem))   
> If the key was DOWN, move the lightItem with 
> QVBoxLayout.insertWidget(min(cur_index+1, layout.count()-1))
> 
> Hope that helps. Let me know if you get stuck on any of the specific code.
> 
> -- justin
> 
> 
> On Oct 8, 2012, at 6:21 PM, Berg Jones wrote:
> 
>> I'm looking for an easy way to move dynamically created splitter widgets 
>> within a vertical layout in pyqt. I know what the hard way is.
>> 
>> I have:
>> 
>> a top level gridlayout
>> a scroll layout
>> a tab layout
>> a vert layout within the tab
>> N dynamically created horizontal splitters
>> The user wants the ability to change the order of the splitters. I build the 
>> light list dynamically according to the number of lights in the scene with 
>> the following:
>> 
>> def buildLightList(self):
>>              lightShapes = cmds.ls(lights=True)
>>              if lightShapes:
>>                      lightTransforms = cmds.listRelatives(lightShapes, 
>> p=True)
>> 
>>                      for i in lightTransforms:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> What I would like is if you press pageUp or PageDn while selecting the 
>> lineEdit widget on the lift this will raise or lower the splitter.
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> -- 
>> view archives: http://groups.google.com/group/python_inside_maya
>> change your subscription settings: 
>> http://groups.google.com/group/python_inside_maya/subscribe
> 

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to