from PySide import QtCore
from PySide import QtGui
class FilePathEditor
( QtGui.
QWidget ): def __init__( self, parent=none, window_flags=QtCore.QtWidget ):
super( FilePathEditor, self ).__init__( parent, window_flags )
self.
browse_button = QtGui.
QPushButton( "Browse...", self
)
layout.setContentsMargins( 0, 0, 0, 0 )
layout.setSpacing( 1 )
layout.addWidget( self.path_line )
layout.addWidget( self.browse_button )
self.setLayout( layout )
self.browse_button.clicked.connect( self.choose_path )
# ... additional methods removed for brevity....
class ParameterItemDelegate( QtGui.QStyledItemDelegate ):
def __init__( self, parent=None ):
super( ParameterItemDelegate, self ).__init__( parent )
def updateEditorGeometry( self, editor, option, index ):
editor.setGeometry( option.rect )
def paint( self, painter, option, index ):
# grab pointer to my internal data structure for each item stored in my tree model.
item = index.internalPointer()
if index.column() == VALUE_COLUMN and item.has_path_data():
# XXX: how to properly draw my custom editor widget?
else:
super( ParameterItemDelegate, self ).paint( painter, option, index )
# ... additional methods removed for brevity....
from PySide import QtCore
from PySide import QtGui
class FilePathEditor( QtGui.QWidget ):
def __init__( self, parent=none, window_flags=QtCore.QtWidget ):
super( FilePathEditor, self ).__init__( parent, window_flags )
self.path_line = QtGui.QLineEdit( self )
self.browse_button = QtGui.QPushButton( "Browse...", self )
layout = QtGui.QHBoxLayout()
layout.setContentsMargins( 0, 0, 0, 0 )
layout.setSpacing( 1 )
layout.addWidget( self.path_line )
layout.addWidget( self.browse_button )
self.setLayout( layout )
self.browse_button.clicked.connect( self.choose_path )
# ... additional methods removed for brevity....
class ParameterItemDelegate( QtGui.QStyledItemDelegate ):
def __init__( self, parent=None ):
super( ParameterItemDelegate, self ).__init__( parent )
def updateEditorGeometry( self, editor, option, index ):
editor.setGeometry( option.rect )
def paint( self, painter, option, index ):
# grab pointer to my internal data structure for each item stored in my tree model.
item = index.internalPointer()
if index.column() == VALUE_COLUMN and item.has_path_data():
# XXX: how to properly draw my custom editor widget?
else:
super( ParameterItemDelegate, self ).paint( painter, option, index )
# ... additional methods removed for brevity....
To copy to clipboard, switch view to plain text mode
Bookmarks