You definitely don't want to be calling any of the begin* methods in this situation.
I think what you are looking for it the save() / restore() methods: http://qt-project.org/doc/qt-4.8/qpainter.html#save That would let you first call save() and then make a bunch of changes to the painter settings like pen and brush and attributes, do your painting, and then restore the painter to its previous state. Make sure to call restore() at the end of the context when you want to revert to the last settings. On 9/09/2014 12:20 PM, "Bay" <[email protected]> wrote: > Hi Justin, > thanks again for all the assistance. Just want to ask one > last question. I've attempted to use the QPen to draw a border for my > selection thumbnails but a problem I'm running into is that it doesn't > clean it self up very well when I attempt to draw a selection box. Is there > a flag I could use to improve this? I've attempted to use painter.begin and > painter.end but it just makes my thumbnail disappear. > > This is the code of my latest attempt. > > if opts.state & QtGui.QStyle.State_Selected: > painter.beginNativePainting() > painter.setRenderHint(painter.Antialiasing, True) > pen = QtGui.QPen(QtCore.Qt.white, 1, QtCore.Qt.SolidLine) > pen.setCosmetic(True) > painter.setPen(pen) > painter.drawRect(opts.rect) > painter.endNativePainting() > > > Thanks again! > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/2433fc89-fcd0-41d9-905d-39186263aa55%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/2433fc89-fcd0-41d9-905d-39186263aa55%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1nCP_Ty%2BShg%2BpNSGZ8YyavBr-rb024pcSUCphTyu6Zvw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
