Hans-Peter Jansen | 1 Feb 01:25

issue with QPainter.drawPolyline and list of QPoints

Hi Phil,

shouldn't this work:

from PyQt4 import QtCore, QtGui
app = QtGui.QApplication([])
pixmap = QtGui.QPixmap(16, 16)
painter = QtGui.QPainter(pixmap)
plist = [QtCore.QPoint(0, 15), QtCore.QPoint(0, 0), QtCore.QPoint(15, 0)]
painter.drawPolyline(plist)

With PyQt 4.9, this results in:

TypeError: arguments did not match any overloaded call:
  QPainter.drawPolyline(QPointF, ...): argument 1 has unexpected type 'list'
  QPainter.drawPolyline(QPolygonF): argument 1 has unexpected type 'list'
  QPainter.drawPolyline(QPoint, ...): argument 1 has unexpected type 'list'
  QPainter.drawPolyline(QPolygon): argument 1 has unexpected type 'list'

QPaintDevice: Cannot destroy paint device that is being painted
Speicherzugriffsfehler

although you provide a %MethodCode handler for the list of QPoints case.
Ref: line 354 in sip/QtGui/qpainter.sip

Hmm,
Pete
JPolk | 1 Feb 03:02
Picon
Favicon

Re: Parent/Child widget clipping

So after tinkering with this a bit more, I'm in another conundrum, lol...

When I replace the 'child-table'  (QTableWidget) with another kind of
widget,
and give a size using 'setGeometry'...the solution no longer works...

Why is that? What am I doing wrong, Pete?

#----------------------------------------------------------------------------------------

#!/usr/bin/env python

import sys
from PyQt4 import QtGui, QtCore

class MainExample(QtGui.QWidget):
    def __init__(self, pParent=None):
        super(MainExample, self).__init__(pParent)

        scrX = 2048
        scrY = 1152
        winX = 550
        winY = 400
        pX   = (scrX - winX) / 2
        pY   = (scrY - winY) / 2

        self.setGeometry(pX, pY, winX, winY)
        self.setLayout(QtGui.QVBoxLayout())
        self.LargeTable = QtGui.QTreeWidget()
        self.LargeTable.setColumnCount(3)
(Continue reading)

Phil Thompson | 1 Feb 09:57

Re: issue with QPainter.drawPolyline and list of QPoints

On Wed, 1 Feb 2012 01:25:57 +0100, "Hans-Peter Jansen" <hpj <at> urpla.net>
wrote:
> Hi Phil,
> 
> shouldn't this work:
> 
> from PyQt4 import QtCore, QtGui
> app = QtGui.QApplication([])
> pixmap = QtGui.QPixmap(16, 16)
> painter = QtGui.QPainter(pixmap)
> plist = [QtCore.QPoint(0, 15), QtCore.QPoint(0, 0), QtCore.QPoint(15,
0)]
> painter.drawPolyline(plist)

No, try...

  painter.drawPolyline(*plist)

Phil
JPolk | 1 Feb 20:47
Picon
Favicon

Re: Parent/Child widget clipping


...not sure if this is the proper or elegant way, but I found a
workaround....by setting minWidth and minHeight

    self.widget.setMinimumWidth(minW)
    self.widget.setMinimumHeight(minH)

...then, once inserted into the TreeWidget, it retains it's height, and
isn't clipped...

--
View this message in context: http://python.6.n6.nabble.com/Parent-Child-widget-clipping-tp4352146p4357177.html
Sent from the PyQt mailing list archive at Nabble.com.
Hans-Peter Jansen | 1 Feb 23:58

Re: issue with QPainter.drawPolyline and list of QPoints

On Wednesday 01 February 2012, 09:57:35 Phil Thompson wrote:
> On Wed, 1 Feb 2012 01:25:57 +0100, "Hans-Peter Jansen"
> <hpj <at> urpla.net>
>
> wrote:
> > Hi Phil,
> >
> > shouldn't this work:
> >
> > from PyQt4 import QtCore, QtGui
> > app = QtGui.QApplication([])
> > pixmap = QtGui.QPixmap(16, 16)
> > painter = QtGui.QPainter(pixmap)
> > plist = [QtCore.QPoint(0, 15), QtCore.QPoint(0, 0),
> > QtCore.QPoint(15,
>
> 0)]
>
> > painter.drawPolyline(plist)
>
> No, try...
>
>   painter.drawPolyline(*plist)

Of course, silly me.

Thanks, Phil.

Pete
(Continue reading)

Hans-Peter Jansen | 2 Feb 00:08

Re: Parent/Child widget clipping

On Wednesday 01 February 2012, 20:47:01 JPolk wrote:
> ...not sure if this is the proper or elegant way, but I found a
> workaround....by setting minWidth and minHeight
>
>     self.widget.setMinimumWidth(minW)
>     self.widget.setMinimumHeight(minH)
>
> ...then, once inserted into the TreeWidget, it retains it's height,
> and isn't clipped...

That's perfectly fine, James. It's the other way around - if you start 
using setGeometry for ui elements (not windows), something is 
conceptually broken in your code. Badly. 

We're using layout manager for a reason. You don't *want* to know their 
innards, unless you have a strong masochistic background. Do you?

Pete
JPolk | 2 Feb 02:37
Picon
Favicon

Can DockWidgets be docked onto anything else except MainWindows?


Can DockWidgets be docked onto anything else except MainWindows ?

Supposed you have either a layout or a widget that's "mid-page" in a window
and want to dock/undock from that layout/widget and not the MainWindow...

Doesn't look to be possible,...Can anyone confirm this?

Thanks!

--
View this message in context: http://python.6.n6.nabble.com/Can-DockWidgets-be-docked-onto-anything-else-except-MainWindows-tp4357906p4357906.html
Sent from the PyQt mailing list archive at Nabble.com.
Andreas Pakulat | 2 Feb 08:55
Picon
Picon
Gravatar

Re: Can DockWidgets be docked onto anything else except MainWindows?

On 01.02.12 17:37:53, JPolk wrote:
> 
> Can DockWidgets be docked onto anything else except MainWindows ?
> 
> Supposed you have either a layout or a widget that's "mid-page" in a window
> and want to dock/undock from that layout/widget and not the MainWindow...
> 
> Doesn't look to be possible,...Can anyone confirm this?

You can, but that requires writing a layout-manager similar to the one
used in QMainWindow (which is not public API so cannot simply be used).

So there's no 'out of the box' way to dock QDockWidgets into normal
QWidgets, but if you put in enough effort you can do that.

Andreas

JPolk | 2 Feb 20:17
Picon
Favicon

Re: Parent/Child widget clipping

LOL, no, not my cup of tea, thank you...
But I appreciate all work that goes into making this PyQt thing fun to use!

And you correctly surmise, that 'setGeom' in there was just for testing,..

Cheers!

--
View this message in context: http://python.6.n6.nabble.com/Parent-Child-widget-clipping-tp4352146p4359822.html
Sent from the PyQt mailing list archive at Nabble.com.
JPolk | 2 Feb 20:19
Picon
Favicon

Re: Can DockWidgets be docked onto anything else except MainWindows?


Thanks for your reply, Andreas

--
View this message in context: http://python.6.n6.nabble.com/Can-DockWidgets-be-docked-onto-anything-else-except-MainWindows-tp4357906p4359825.html
Sent from the PyQt mailing list archive at Nabble.com.

Gmane