def paintEvent(self, e): #data = self.itemData(self.currentIndex()) data = NWM.intToStyle(NWM.LINE_STYLE_LIST[self.currentIndex()]) line_color = self.network_index.model().createIndex(self.network_index.row(), NWM.NET_COLOR).data() #line_color = self.network_index.model().data(self.network_index.row(), # WLM.NET_COLOR) p = QStylePainter(self) p.setPen(self.palette().color(QPalette.Text)) opt = QStyleOptionComboBox() self.initStyleOption(opt) p.drawComplexControl(QStyle.CC_ComboBox, opt) painter = QPainter(self) painter.save() rect = p.style().subElementRect(QStyle.SE_ComboBoxFocusRect, opt, self) rect.adjust(+5, 0, -5, 0) pen = QPen() pen.setColor(line_color) pen.setWidth(3) pen.setStyle(data) painter.setPen(pen) middle = (rect.bottom() + rect.top()) / 2 painter.drawLine(rect.left(), middle, rect.right(), middle) painter.restore()
def paint(self, painter, option, index): data = NWM.intToStyle(int(index.data())) line_color = self.network_index.model().createIndex(self.network_index.row(), NWM.NET_COLOR).data() #line_color = self.network_model.data(index.row(), WLM.NET_COLOR) painter.save() rect = option.rect rect.adjust(+5, 0, -5, 0) pen = QPen() pen.setColor(line_color) pen.setWidth(3) pen.setStyle(data) painter.setPen(pen) middle = (rect.bottom() + rect.top()) / 2 painter.drawLine(rect.left(), middle, rect.right(), middle) painter.restore()