Ignore:
Timestamp:
11/06/12 13:48:32 (18 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Compatibility fixes for PyQt4 < 4.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/canvas/items/utils.py

    r11102 r11172  
    11import numpy 
    22 
    3 from PyQt4.QtGui import QColor, QRadialGradient 
     3from PyQt4.QtGui import QColor, QRadialGradient, QGraphicsItem 
    44 
    55 
     
    4141    gradient.setCoordinateMode(QRadialGradient.ObjectBoundingMode) 
    4242    return gradient 
     43 
     44 
     45def toGraphicsObjectIfPossible(item): 
     46    """Return the item as a QGraphicsObject if possible. 
     47 
     48    This function is intended as a workaround for a problem with older 
     49    versions of PyQt (< 4.9), where methods returning 'QGraphicsItem *' 
     50    lose the type of the QGraphicsObject subclasses and instead return 
     51    generic QGraphicsItem wrappers. 
     52 
     53    """ 
     54    obj = item.toGraphicsObject() 
     55    return item if obj is None else obj 
Note: See TracChangeset for help on using the changeset viewer.