No need to do any manual painting. To be more specific:

1. Use arrayToQPath to generate a QPainterPath object (this describes just
the coordinates of lines in the path)
2. Create a QGraphicsPathItem using the QPainterPath as its input
3. Add the QGraphicsPathItem to the ViewBox or PlotItem
4. Probably you will also need to set the pen/brush on the QGraphicsPathItem

Text can be added anywhere in much the same way, with QGraphicsTextItem.
The important thing here, though, is that you do not want to add the text
into the viewbox like you did with the path (because you don't want the
text to scale/translate with the view). Instead, make the ViewBox or
PlotItem the *parent* of the text item. For example:

    plt = pg.plot()
    text = pg.QtGui.QGraphicsTextItem("Hello")
    text.setDefaultTextColor(pg.mkColor('w'))
    text.setParentItem(plt.plotItem)   # this is not the same as
plt.plotItem.addItem(text)



On Mon, May 14, 2018 at 8:55 AM, Robert Budzyński <[email protected]>
wrote:

>
>
> On Saturday, May 12, 2018 at 7:28:02 PM UTC+2, Luke Campagnola wrote:
>>
>> Qt provides several lower-level drawing primitives. In this case, you
>> probably want QGraphicsPathItem: http://doc.qt.io/archives/qt-4
>> .8/qgraphicspathitem.html
>>
>> You could also use pg.arrayToQPath to generate the QPath:
>> http://www.pyqtgraph.org/documentation/functions.html#pyqtgr
>> aph.arrayToQPath
>>
>>
>>
> More specifically, this QPainterPath should be painted on some QWidget,
> and I can't figure out which. My guess was the ViewBox, but I get:
>
> TypeError: arguments did not match any overloaded call:
>  QPainter(): too many arguments
>  QPainter(QPaintDevice): argument 1 has unexpected type 'ViewBox'
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "pyqtgraph" 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/pyqtgraph/6f927042-b73a-4d4e-ac81-4b7e084d8a8e%40googlegroups.com
> <https://groups.google.com/d/msgid/pyqtgraph/6f927042-b73a-4d4e-ac81-4b7e084d8a8e%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 
"pyqtgraph" 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/pyqtgraph/CACZXET8Xj4aUcoJQtG8aEGRwT_K5w9JRp5R0k4USZrQPgZpCFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to