Wojciech Daniło | 15 May 2013 15:58
Picon

PyQt5 QtQuick 2.0 binding

Hi! Is PyQt5 working with QtQuick2.0? 
<div><div dir="ltr">Hi! Is PyQt5 working with QtQuick2.0?&nbsp;</div></div>
Wojciech Daniło | 15 May 2013 14:23
Picon

PyQt5 installation problem

Hi!
When I'm trying to install PyQt5 I get an error: Error: PyQt5 requires Qt v5.0 or later.

My Qt5.0.2 installation is in my $HOME/dev/Qt5.0.2 - how can I tell the configure script to search for it there?

<div><div dir="ltr">Hi!<div>When I'm trying to install PyQt5 I get an error: Error: PyQt5 requires Qt v5.0 or later.</div>
<div><br></div>
<div>My Qt5.0.2 installation is in my $HOME/dev/Qt5.0.2 - how can I tell the configure script to search for it there?</div>
<div><br></div>
</div></div>
David Boddie | 14 May 2013 22:21
Picon
Gravatar

Re: Paste entire column into QTableView from Excel

On Mon 13 May 2013 15:12:41 -0400, Mark Mordeca wrote:

> I am having an issue pasting into a QTableView from Excel when the user has
> copied by selecting an entire column in Excel, essentially putting every
> single row in the selected column, for the entire excel sheet, on the
> clipboard. The following is my paste code for QTableView:

[...]

> This all works fine when a user has selected just a bunch of cells in Excel
> and copied those. It breaks down when they select an entire column because
> pasteString then becomes upwards of 1048576 characters long (this value is
> found by printing pasteString.size() when highlighting a completely empty
> Excel column by selecting its header and copying).  It completely kills the
> program.

Does it crash or just become unresponsive?

Is there a limit on the amount of data that can be stored in the clipboard
on Windows? Maybe that could be a factor. Can you paste the whole column into
another application successfully?

> Is there any way to get the copied column from the clipboard more
> efficiently than tab delimited text or something? Or should I just throw up
> an error when the size of the string on the clipboard is some arbitrarily
> large length?  Any help would be appreciated.

You need to check what sort of MIME data is contained in the clipboard. The
QClipboard documentation should have example code for this.

David
andre hotz | 14 May 2013 17:15
Favicon

resizing layouts

Hi all,

If have a quick question regarding qt layouts.
My application has 4 areas, defined by a 2x2 QGridLayout. Each area can 
have single widgets and also sub layouts.
Now I want the user to be able to interactivly change the size of each 
of the 4 areas by a handle.
Basically what a QSplitter does, but QSplitter seems only to work on 
widgets, not on complete layouts.

Anyone has an idea to solve this?

Thanks,
Andre

Mark Mordeca | 13 May 2013 21:12
Picon
Favicon

Paste entire column into QTableView from Excel

Greetings,

I am having an issue pasting into a QTableView from Excel when the user has copied by selecting an entire column in Excel, essentially putting every single row in the selected column, for the entire excel sheet, on the clipboard. The following is my paste code for QTableView:

   def paste(self):

        model=self.model()

        pasteString=QtGui.QApplication.clipboard().text()

 

        rows=pasteString.split('\n')

        numRows=len(rows)

        numCols=rows[0].count('\t')+1

 

        selectionRanges=self.selectionModel().selection()

 

        #make sure we only have one selection range and not non-contiguous selections

        if len(selectionRanges)==1:

            topLeftIndex=selectionRanges[0].topLeft()

            selColumn=topLeftIndex.column()

            selRow=topLeftIndex.row()

            if selColumn+numCols>model.columnCount():

                #the number of columns we have to paste, starting at the selected cell, go beyond how many columns exist.

                #insert the amount of columns we need to accomodate the paste

                model.insertColumns(model.columnCount(), numCols-(model.columnCount()-selColumn))

 

            if selRow+numRows>model.rowCount():

                #the number of rows we have to paste, starting at the selected cell, go beyond how many rows exist.

                #insert the amount of rows we need to accomodate the paste

                model.insertRows(model.rowCount(), numRows-(model.rowCount()-selRow))

 

            #block signals so that the "dataChanged" signal from setData doesn't update the view for every cell we set

            model.blockSignals(True) 

 

            for row in xrange(numRows):

                columns=rows[row].split('\t')

 

                [model.setData(model.createIndex(selRow+row, selColumn+col), QVariant(columns[col])) for col in xrange(len(columns))]

 

            #unblock the signal and emit dataChangesd ourselves to update all the view at once

            model.blockSignals(False)

            model.dataChanged.emit(topLeftIndex, model.createIndex(selRow+numRows, selColumn+numCols))

This all works fine when a user has selected just a bunch of cells in Excel and copied those. It breaks down when they select an entire column because pasteString then becomes upwards of 1048576 characters long (this value is found by printing pasteString.size() when highlighting a completely empty Excel column by selecting its header and copying).  It completely kills the program.

Is there any way to get the copied column from the clipboard more efficiently than tab delimited text or something? Or should I just throw up an error when the size of the string on the clipboard is some arbitrarily large length?  Any help would be appreciated.

Thanks,

Mark

 

<div><div class="WordSection1">
<p class="MsoNormal"><span>Greetings,</span></p>
<p class="MsoNormal"><span>I am having an issue pasting into a QTableView from Excel when the user has copied by selecting an entire column in Excel, essentially putting every single row in the selected column, for the entire excel sheet, on the clipboard. The following is my paste code for QTableView:</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp; def paste(self):</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; model=self.model()</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pasteString=QtGui.QApplication.clipboard().text()</span></p>
<p class="MsoNormal"><span>&nbsp;</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rows=pasteString.split('\n')</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; numRows=len(rows)</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; numCols=rows[0].count('\t')+1</span></p>
<p class="MsoNormal"><span>&nbsp;</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selectionRanges=self.selectionModel().selection()</span></p>
<p class="MsoNormal"><span>&nbsp;</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #make sure we only have one selection range and not non-contiguous selections</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if len(selectionRanges)==1:</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; topLeftIndex=selectionRanges[0].topLeft()</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selColumn=topLeftIndex.column()</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selRow=topLeftIndex.row()</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if selColumn+numCols&gt;model.columnCount():</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #the number of columns we have to paste, starting at the selected cell, go beyond how many columns exist.</span></p>
<p class="MsoNormal">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #insert the amount of columns we need to accomodate the paste</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; model.insertColumns(model.columnCount(), numCols-(model.columnCount()-selColumn))</span></p>
<p class="MsoNormal"><span>&nbsp;</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if selRow+numRows&gt;model.rowCount():</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#the number of rows we have to paste, starting at the selected cell, go beyond how many rows exist.</span></p>
<p class="MsoNormal">
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #insert the amount of rows we need to accomodate the paste</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; model.insertRows(model.rowCount(), numRows-(model.rowCount()-selRow))</span></p>
<p class="MsoNormal"><span>&nbsp;</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #block signals so that the "dataChanged" signal from setData doesn't update the view for every cell we set</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; model.blockSignals(True)&nbsp; </span></p>
<p class="MsoNormal"><span>&nbsp;</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for row in xrange(numRows):</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; columns=rows[row].split('\t')</span></p>
<p class="MsoNormal"><span>&nbsp;</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [model.setData(model.createIndex(selRow+row, selColumn+col), QVariant(columns[col])) for col in xrange(len(columns))]</span></p>
<p class="MsoNormal"><span>&nbsp;</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #unblock the signal and emit dataChangesd ourselves to update all the view at once</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; model.blockSignals(False)</span></p>
<p class="MsoNormal"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; model.dataChanged.emit(topLeftIndex, model.createIndex(selRow+numRows, selColumn+numCols))</span></p>
<p class="MsoNormal"><span>This all works fine when a user has selected just a bunch of cells in Excel and copied those. It breaks down when they select an entire column because </span><span>pasteString</span><span> then becomes upwards of 1048576 characters long (this value is found by printing pasteString.size() when highlighting a completely empty Excel column by selecting its header and copying).&nbsp; It completely kills the program.</span></p>
<p class="MsoNormal"><span>Is there any way to get the copied column from the clipboard more efficiently than tab delimited text or something? Or should I just throw up an error when the size of the string on the clipboard is some arbitrarily large length?&nbsp; Any help would be appreciated.</span></p>
<p class="MsoNormal"><span>Thanks,</span></p>
<p class="MsoNormal"><span>Mark</span></p>
<p class="MsoNormal">&nbsp;</p>
</div></div>
Mathias.Born | 12 May 2013 22:42
Picon
Picon

PyQt5 Snapshot, build problems and their solutions, Windows, mingw

Hi,

I've compiled the latest PyQt5 snaphot, on 32bit python 3.3.1 (compiled with mingw, using a self-made
build script based on scons), Windows7, Qt 5.1alpha.

I've used this configuration step:

D:\_cpp_projects_\Python\Python-3.3.1\.build_release\python.exe configure.py --no-docstrings
--confirm-license -u --spec=win32-g++ --verbose --trace
--sip="D:\_cpp_projects_\Python\Python-3.3.1\sip.exe"
LFLAGS+="-LD:\_cpp_projects_\Python\Python-3.3.1\.build_debug
-LD:\_cpp_projects_\Python\Python-3.3.1\.build_release" DEFINES+=_DEBUG

(It's necessary to include the release version of the python lib even in debug build for the designer
plugins.)

I've run into a number of problems:

(1)
PyQt's configure.py autoamtically assumes certain MS-compilers on the win32 platform, in
TargetConfiguration.__init__():262 and following:

        # The default qmake spec.
        if sys.platform == 'win32':
            if self.py_version >= 0x030300:
                #self.qmake_spec = 'win32-msvc2010'
----            self.qmake_spec = 'win32-g++'
            elif self.py_version >= 0x020600:
                self.qmake_spec = 'win32-msvc2008'
            elif self.py_version >= 0x020400:
                self.qmake_spec = 'win32-msvc.net'
            else:
                self.qmake_spec = 'win32-msvc'
        else:
            # Use the Qt default.  (We may update it for MacOS/X later.)
            self.qmake_spec = ''

I had to make the marked change to get around that for my mingw-based python. It would be nice
if there was an option to influence that.

[Motivation: I must embedd the python interpreter, and I want to get away from MS Visual Studio,
because it is becoming slower with each version. Hence I'll have to compile python myself using
mingw, which is non-standard.]

(2)
All makefiles attempt to build all DLLs without referring to the python DLL. Adding
"-lpython33_d" to each Makefile.Debug and "-lpython33" to Makefile.Release solves this.

I tried adding LFLAGS_DEBUG+="-lpython33_d" as parameter to the configure script, but it had
no effect on the makefiles.

(3)
The final debugging versions of the DLLs get the wrong names. They all miss the trailing "_d".
This way they can't be imported, unless manually renamed arcordingly.

Best Regards,
Mathias Born

David Cortesi | 12 May 2013 22:19
Picon

General questions on parsing large QStrings

For an app to be built with PyQt5/Qt5, I will have a
QPlainTextEdit in which the document may be quite
sizable, 500K characters or more.

I will want at times to inspect the document character
by character, or possibly apply Python relib REs to it.

I am somewhat at sea regarding the relationship between
a const QString such as returned by QPlainTextEdit.toPlainText()
and a Python3 unicode string, and -- just in general -- about
the best way to do intensive examination of big strings.
Is there a copy involved in, e.g.

    docstring = unicode( myEditor.toPlainText() )

I note that the PyQt4 QString reference omits the
QString.begin() or .constBegin() etc methods that return an
"STL-style iterator" so that's out. Is there some internal magic
to integrate the QString type into Python's "for" mechanism
so that "for c in myEditor.toPlainText()" might be more
efficient than making a Python3 string and iterating on it?

Also in regard to making intensive loops faster,
how well do PyQtx calls integrate with Cython or PyPy?

Thanks for any insights,

Dave Cortesi

<div><div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>For an app to be built with PyQt5/Qt5, I will have a<br>
</div>QPlainTextEdit in which the document may be quite<br>sizable, 500K characters or more.<br><br>I will want at times to inspect the document character<br>

by character, or possibly apply Python relib REs to it.<br><br>
</div>I am somewhat at sea regarding the relationship between<br>a const QString such as returned by QPlainTextEdit.toPlainText()<br>
</div>and a Python3 unicode string, and -- just in general -- about<br>

the best way to do intensive examination of big strings.<br>Is there a copy involved in, e.g.<br><br>
</div>&nbsp;&nbsp;&nbsp; docstring = unicode( myEditor.toPlainText() )<br><br>
</div>I note that the PyQt4 QString reference omits the <br>
</div>QString.begin() or .constBegin() etc methods that return an<br>
</div>"STL-style iterator" so that's out. Is there some internal magic<br>
</div>to integrate the QString type into Python's "for" mechanism<br>
</div>so that "for c in myEditor.toPlainText()" might be more<br>
</div>
<div>efficient than making a Python3 string and iterating on it?<br><br>
</div>
<div>
<div>Also in regard to making intensive loops faster, <br>

how well do PyQtx calls integrate with Cython or PyPy?<br><br>
</div>
<div>Thanks for any insights,<br><br>Dave Cortesi<br>
</div>
<div><br></div>
</div>
</div></div>
David Boddie | 11 May 2013 01:27
Picon
Gravatar

Re: Designer Customer Widget

On Wed, 08 May 2013 15:20:26 -0500, Stephen Funkhouser wrote:

[...]

> Is it possible to get Qt Designer to save custom properties of the 
> inherited QTreeWidgetItems objects?

I guess it's more of a Qt Designer question than a PyQt question but you
would need to find out if a C++ custom widget suffers from the same
problem to be sure.

It's been a long time since I looked at Designer. It may be that it only
only saves certain properties out to .ui files, but there may also be a
problem with how it examines custom properties and how those are registered
using PyQt. The only vague recollection I have, apart from realising that
Qt relies on information that is usually provided by plugins at compile time,
is the thought that custom property types seemed difficult to do with PyQt.
Custom properties themselves should be OK - I think.

It might be a long shot, but have you looked at the PyQt examples to see if
any do something similar to what you are doing?

David
Gour | 10 May 2013 11:47
Gravatar

status of PyPy support

Hello,

what is the status of PyPy support for PyQt?

The PyPy compatibility wiki page
(https://bitbucket.org/pypy/compatibility/wiki/Home#!gui-library-bindings)
just says 'Unknown' ?

Sincerely,
Gour

--

-- 
Not by merely abstaining from work can one achieve freedom 
from reaction, nor by renunciation alone can one attain perfection.

http://www.atmarama.net | Hlapicina (Croatia) | GPG: 52B5C810

Christoffer Hulusjo | 10 May 2013 03:11
Favicon

PyQt5 and QtMultimediaWidgets

Hi,

I was able to build the PyQt5 development snapshot against Qt5.0.2 on 
Linux and started playing around with it.
I attempted to port one of the examples from the Qt5.0.2 c++ source,  
/examples/multimediawidgets/videographicsitem, but it seems that some Qt 
libraries/classes were skipped when I built PyQt5?

In the example I attempted I need the QGraphicsVideoItem class from the 
QtMultimediaWidgets namespace.

Any ideas? Will this one be added later?

Cheers
Christoffer

Stephen Funkhouser | 8 May 2013 22:20

Designer Customer Widget

I'm working on creating a custom widget inherited from QTreeWidget. The 
purpose of this is I'm using the Designer for another programming 
language which doesn't have any of it's own developer tools.  I'm 
creating custom widgets to mimic each of this programming language's 
widgets.  The language has a tree control that I can mimic using 
QTreeWidget, but I need to add a lot of custom properties to the Tree 
columns.  I'm trying to do this by inheriting from QTreeWidgetItems to 
create custom items that have unique properties.  I'm also overriding 
the default TreeWidget Editor by creating a Menu Entry, and a Menu 
Factory that calls a custom dialog to edit the custom widget.  In this 
custom dialog I'm adding a header using setHeaderItem(); which, displays 
properly in Qt Designer.  The problem though, is that it the text 
property of the columns isn't being saved to the .ui file.  Designer 
does add column tags to the .ui file, but the text is just the column 
numbers and not my text added through the QExtensionFactory call to the 
dialog.

Is it possible to get Qt Designer to save custom properties of the 
inherited QTreeWidgetItems objects?

Stephen

Gmane