This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Plasmoid: z-Index of a QRect rectangle?

Tags: None
(comma "," separated)
incunabulum
Registered Member
Posts
4
Karma
0
Hi there,

for a plasmoid I want to deterime the z-index of three objects / items shown on the plasmoid. These items are shown overlapping, so that the z-order (bottom to top) is of importance. For two items, I am using native plasma widgets wher the z-index can be defined upon initialization as follows (python)

Code: Select all
class CpuAndSystemViewer(plasmascript.Applet):
   
    ...

    def init(self,parent,args=None):
        self.chart = Plasma.SignalPlotter(self.applet)
        self.chart.setZValue(1)
        self.layout.addItem(self.chart, 0, 0)
           
        self.label = Plasma.Label(self.applet)
        self.label.setZValue(3)
        self.layout.addItem(self.label,  0 ,  0)


For the third item which should get z-index = 2 I am currently using QPainter and a QRect object of certain dimensions and position with translucency as follows:
Code: Select all
   
  def paintInterface(self, painter, option, rect):
     textRect = QRect(rect, ...)
     ...
     painter.drawRoundedRect(textRect, rad1, rad2, Qt.RelativeSize)

Well, as expected the QRect is drawn below everything else (chart + label) and not above the chart but below the label. So, does anyone know how I can change this QRect construct into full scale plasma objects which support setting the z-layer?

Or is there a better place to ask such questions?
incunabulum
Registered Member
Posts
4
Karma
0
Well, more thinking finally brought a solution. Subclass Plasma.Label, reimplement the paint() function with my code and - voila - you get correct z-Layering for these three objects.

Not the easiest but probably the most clean solution.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft