Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread V. Armando Solé

Phil Thompson wrote:

On Wed, 03 Jun 2009 22:57:32 +0200, Vicente Sole wrote:
  
createIndex can accept a pointer or a quint32 so, in any case one  
would say it is a positive number. Perhaps forcing the return of  
internalId() to be a quint64 instead of qint64 in  
qabstractitemmodel.sip could do the job, but then we would not be  
respecting the (incorrect) Qt API.


So, unless I get I successful test under 32-bit with Phil\'s patch, I  
would just leave the things as they are.



Except that this keeps coming up.

Does changing the type of internalId() from qint64 to quint64 solve the
problem (I don't have a 32 bit Linux system handy)?
  


No, it does not.

With your patch and changing the returned value of internalId() to 
quint32 I got it working on 32-bit for both cases, that means, when 
passing the object and when passing the address of the object. So, I 
guess internalId() should return an unsigned int32 in a 32-bit platform 
and an unsigned int64 in a 64-bit platform.


Changing qabstractitemmodel.sip from:

qint64 internalId() const;

to

unsigned long internalId() const;

gives correct results for the object case under the platforms I can test.

For the value case, it works under 32-bit but most likely will fail 
under 64-bit when the written number cannot be represented by a 32-bit 
integer.


I do not know if my "unsigned long" patch can have side effects on other 
platforms. It makes sense that if one passes an object and the address 
of the object is stored, one should get back an unsigned of the type the 
machine is using  for addresses. I always thought it is  unsigned long, 
but perhaps there are more exotic solutions around. Is it possible to 
modify qabstractitemmodel.sip set the returned value as quint32 on 
32-bit platforms and quint64 on 64-bit platforms? That should solve the 
issue I am finding without (hopefully) introducing new ones.


Armando




___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Static Qt/PyQt on Mac OS X

2009-06-03 Thread Giovanni Bajo
On Wed, 03 Jun 2009 20:37:56 +0100, Jeremy Sanders
 wrote:
> Are statically linked PyQt and Qt libraries supported on Mac OS X? If so,
> is 
> there a guide to building them?
> 
> I'm finding it a bit of a pain to get my application packaged with py2app
> as 
> it leaves out the plugins and I have to copy them in by hand and mess
> around 
> with linking paths.
> 
> It would be nice if someone with some Mac OS X experience could have a
look
> 
> at putting a working PyQt recipe into py2app to solve these problems.

Hi Jeremy,

PyInstaller handles PyQt's plugins automatically for you. If you get
PyInstaller SVN trunk, you should get working Mac OSX support; the only
issue is that it does not create a bundle yet (but a patch for this will be
merged later this week).
-- 
Giovanni Bajo
Develer S.r.l.
http://www.develer.com
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Darren Dale
On Wed, Jun 3, 2009 at 4:57 PM, Vicente Sole  wrote:

> Quoting Darren Dale:
>
>  On Wed, Jun 3, 2009 at 2:40 PM, Darren Dale  wrote:
>>
>> One last point, however: I think Armando's suggestion of passing the
>> object,
>> and not the object's id(), coupled with Phil's patch, is the right
>> solution:
>>
>>
> At my side, passing the object was already fine on 64-bit without Phil's
> patch. It is under 32-bit that the check has to be made.
>

Yes, I got confused and part of my post was noise. Phil's patch does not
address passing an object to createIndex.

Darren
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Vicente Sole

Quoting Phil Thompson:


On Wed, 03 Jun 2009 22:57:32 +0200, Vicente Sole:


So, unless I get I successful test under 32-bit with Phil\'s patch, I
would just leave the things as they are.


Except that this keeps coming up.

Does changing the type of internalId() from qint64 to quint64 solve the
problem (I don't have a 32 bit Linux system handy)?



I do not have it at home either. I will test it tomorrow.

Armando
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Phil Thompson
On Wed, 03 Jun 2009 22:57:32 +0200, Vicente Sole  wrote:
> Quoting Darren Dale:
> 
>> On Wed, Jun 3, 2009 at 2:40 PM, Darren Dale  wrote:
>>
>> One last point, however: I think Armando's suggestion of passing the
>> object,
>> and not the object's id(), coupled with Phil's patch, is the right
>> solution:
>>
> 
> At my side, passing the object was already fine on 64-bit without  
> Phil's patch. It is under 32-bit that the check has to be made.
> 
> If I have understood Phil's patch, it tries to set a long into an  
> unsigned 32bit. Darren has already found it does not work under 64 bit  
> for the case of passing the address of the object.
> 
> Since Trolltech already decided not to fix their bug, I would just  
> leave the things as they are concerning PyQt. The alternative of  
> passing the object works as it should in most cases. The cases where  
> retrieving the object address via the call to internalID() fail are  
> easy to catch because at the python side one receives a negative  
> number when one is expecting a positive number and it can be converted  
> as in the example I sent previously.
> 
> createIndex can accept a pointer or a quint32 so, in any case one  
> would say it is a positive number. Perhaps forcing the return of  
> internalId() to be a quint64 instead of qint64 in  
> qabstractitemmodel.sip could do the job, but then we would not be  
> respecting the (incorrect) Qt API.
> 
> So, unless I get I successful test under 32-bit with Phil\'s patch, I  
> would just leave the things as they are.

Except that this keeps coming up.

Does changing the type of internalId() from qint64 to quint64 solve the
problem (I don't have a 32 bit Linux system handy)?

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Vicente Sole

Quoting Darren Dale:


On Wed, Jun 3, 2009 at 2:40 PM, Darren Dale  wrote:

One last point, however: I think Armando's suggestion of passing the object,
and not the object's id(), coupled with Phil's patch, is the right solution:



At my side, passing the object was already fine on 64-bit without  
Phil's patch. It is under 32-bit that the check has to be made.


If I have understood Phil's patch, it tries to set a long into an  
unsigned 32bit. Darren has already found it does not work under 64 bit  
for the case of passing the address of the object.


Since Trolltech already decided not to fix their bug, I would just  
leave the things as they are concerning PyQt. The alternative of  
passing the object works as it should in most cases. The cases where  
retrieving the object address via the call to internalID() fail are  
easy to catch because at the python side one receives a negative  
number when one is expecting a positive number and it can be converted  
as in the example I sent previously.


createIndex can accept a pointer or a quint32 so, in any case one  
would say it is a positive number. Perhaps forcing the return of  
internalId() to be a quint64 instead of qint64 in  
qabstractitemmodel.sip could do the job, but then we would not be  
respecting the (incorrect) Qt API.


So, unless I get I successful test under 32-bit with Phil\'s patch, I  
would just leave the things as they are.


Armando

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Static Qt/PyQt on Mac OS X

2009-06-03 Thread nenduvel

Jeremy,

I'm not sure if I understand your question. But I'm using a mac with osx and
pyqt is installed with me. I used darwinports and this installed pyqt with
all needed dependencies. you can compare darwinports with the port system on
bsd-variants and the package system at linux.

hope it helps,

nenduvel


Bugzilla from jer...@jeremysanders.net wrote:
> 
> Are statically linked PyQt and Qt libraries supported on Mac OS X? If so,
> is 
> there a guide to building them?
> 
> I'm finding it a bit of a pain to get my application packaged with py2app
> as 
> it leaves out the plugins and I have to copy them in by hand and mess
> around 
> with linking paths.
> 
> It would be nice if someone with some Mac OS X experience could have a
> look 
> at putting a working PyQt recipe into py2app to solve these problems.
> 
> Thanks
> 
> Jeremy
> 
> -- 
> http://www.jeremysanders.net/
> 
> 
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Static-Qt-PyQt-on-Mac-OS-X-tp23858220p23859064.html
Sent from the PyQt mailing list archive at Nabble.com.

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Static Qt/PyQt on Mac OS X

2009-06-03 Thread Jeremy Sanders
Are statically linked PyQt and Qt libraries supported on Mac OS X? If so, is 
there a guide to building them?

I'm finding it a bit of a pain to get my application packaged with py2app as 
it leaves out the plugins and I have to copy them in by hand and mess around 
with linking paths.

It would be nice if someone with some Mac OS X experience could have a look 
at putting a working PyQt recipe into py2app to solve these problems.

Thanks

Jeremy

-- 
http://www.jeremysanders.net/


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] connect method launched command

2009-06-03 Thread nenduvel

hi,

I'm having trouble with the signal/slot messages. I'm trying to catch a
signal and then execute a method that i wrote. But instead of waiting for
the signal it executes the method when i call the connect method.

I make a wizard with a page. the page has a toolbar with an icon.

qWizard = QWizard()
qPage = QWizardPage()
openToolBar = QToolBar()
self.openAct = QtGui.QAction(QtGui.QIcon(QString('open.png')), 'Open File',
openToolBar) openToolBar.connect(self.openAct, QtCore.SIGNAL('triggered()'),
self.showOpenFileDialog(qPage))

does anybody know what i'm doing wrong? Or do you know another way to catch
the triggered() signal and execute the code of the
showOpenFileDialog-method? 

thanks in advance,

nenduvel
-- 
View this message in context: 
http://www.nabble.com/connect-method-launched-command-tp23840766p23840766.html
Sent from the PyQt mailing list archive at Nabble.com.

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Darren Dale
On Wed, Jun 3, 2009 at 2:40 PM, Darren Dale  wrote:

> On Wed, Jun 3, 2009 at 2:20 PM, Darren Dale  wrote:
>
>> On Wed, Jun 3, 2009 at 12:08 PM, Phil Thompson <
>> p...@riverbankcomputing.com> wrote:
>>
>>> On Wed, 03 Jun 2009 17:37:29 +0200, "V. Armando Solé" 
>>> wrote:
>>> > Hello,
>>> >
>>> > The problem can be solved as shown below.
>>> >
>>> > It seems the linux 32 bit implementation gets confused in
>>> > createIndex(row, column, a) when a is not an integer but a long. With
>>> > small values of a (10, 100, 1000),  the indexId() method returns the
>>> > supplied value.
>>> >
>>> > The solution is to call createIndex(row, column, a) with a being a
>>> > python object and not its id. The indexId() method can be masked with a
>>> > 32 bit mask if it returns a negative value. I have only found that
>>> > misbehavior under linux 32bit. Windows XP and linux 64-bit behave
>>> properly.
>>> >
>>> > Thanks for your time,
>>> >
>>> > Armando
>>> >
>>> > import PyQt4.Qt as qt
>>> > import random
>>> > import sys
>>> >
>>> > mask = 0x
>>> >
>>> > class Model(qt.QAbstractItemModel):
>>> >   def index(self, row, column, parent):
>>> >   a=[random.random()]
>>> >   index =  self.createIndex(row, column, a)
>>> >   print "Next two values should be the same"
>>> >   returned = index.internalId()
>>> >   if returned < 0:
>>> >   returned = returned & mask
>>> >   print "indexInternalId = ", returned
>>> >   print "id(a) = ", id(a)
>>> >   print "Forcing to be the same with a 32 bit mask"
>>> >   print "indexInternalId = ", index.internalId() & mask
>>> >   print "id(a) = ", id(a) & mask
>>> >   return index
>>> >
>>> > if __name__ == "__main__":
>>> >   app = qt.QApplication([])
>>> >   w = Model()
>>> >   w.index(0,0,None)
>>>
>>> Could you see if the problem goes away if you change
>>> qabstractitemmodel.sip
>>> so that...
>>>
>>>QModelIndex createIndex(int arow, int acolumn, int aid) const;
>>>
>>> ...is replaced by...
>>>
>>>QModelIndex createIndex(int arow, int acolumn, quint32 aid) const;
>>>
>>
>> I applied this change to the 20090601 snapshot. Executive summary: when I
>> check different data types, I can still find places where the two id's do
>> not agree. I find disagreement with the mask applied and without:
>>
>> When I run the script I posted, I get output like:
>>
>> Next two values should be the same
>> indexInternalId =  1849945336
>> id(a) =  139691366280440
>>
>> If I apply Armando's mask, I get:
>>
>> Next two values should be the same
>> indexInternalId =  12719168
>> id(a) =  12719168
>>
>> If I remove the mask and instead do "a=[numpy.uint32(random.random())]", I
>> get ouput like:
>>
>> Next two values should be the same
>> indexInternalId =  12719168
>> id(a) =  12719168
>>
>> Still without the mask, if I do "a=[numpy.int64(random.random())]":
>>
>> Next two values should be the same
>> indexInternalId =  12719168
>> id(a) =  12719168
>>
>> And finally, with Armando's mask and with
>> "a=[numpy.int64(random.random())]":
>>
>> Next two values should be the same
>> indexInternalId =  110072896
>> id(a) =  139754050917440
>>
>
> There was a bug report, it has been marked "won't fix":
> http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=204226
>

One last point, however: I think Armando's suggestion of passing the object,
and not the object's id(), coupled with Phil's patch, is the right solution:

import PyQt4.Qt as qt

import random
import sys

import numpy

class Model(qt.QAbstractItemModel):
  def index(self, row, column, parent):
  a=(random.random(),)
  index =  self.createIndex(row, column, a)
  print "Next two values should be the same"
  print "indexInternalId = ", index.internalId()
  print "id(a) = ", id(a)

  a=(numpy.uint32(random.random()),)
  index =  self.createIndex(row, column, a)
  print "Next two values should be the same"
  print "indexInternalId = ", index.internalId()
  print "id(a) = ", id(a)

  a=(numpy.uint64(random.random()),)
  index =  self.createIndex(row, column, a)
  print "Next two values should be the same"
  print "indexInternalId = ", index.internalId()
  print "id(a) = ", id(a)

  return index

if __name__ == "__main__":
  app = qt.QApplication([])
  w = Model()
  w.index(0,0,None)


With Phil's patch, running this script on 64-bit linux yields:

Next two values should be the same
indexInternalId =  8744016
id(a) =  8744016
Next two values should be the same
indexInternalId =  8744080
id(a) =  8744080
Next two values should be the same
indexInternalId =  8744016
id(a) =  8744016

Darren
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Darren Dale
On Wed, Jun 3, 2009 at 2:20 PM, Darren Dale  wrote:

> On Wed, Jun 3, 2009 at 12:08 PM, Phil Thompson <
> p...@riverbankcomputing.com> wrote:
>
>> On Wed, 03 Jun 2009 17:37:29 +0200, "V. Armando Solé" 
>> wrote:
>> > Hello,
>> >
>> > The problem can be solved as shown below.
>> >
>> > It seems the linux 32 bit implementation gets confused in
>> > createIndex(row, column, a) when a is not an integer but a long. With
>> > small values of a (10, 100, 1000),  the indexId() method returns the
>> > supplied value.
>> >
>> > The solution is to call createIndex(row, column, a) with a being a
>> > python object and not its id. The indexId() method can be masked with a
>> > 32 bit mask if it returns a negative value. I have only found that
>> > misbehavior under linux 32bit. Windows XP and linux 64-bit behave
>> properly.
>> >
>> > Thanks for your time,
>> >
>> > Armando
>> >
>> > import PyQt4.Qt as qt
>> > import random
>> > import sys
>> >
>> > mask = 0x
>> >
>> > class Model(qt.QAbstractItemModel):
>> >   def index(self, row, column, parent):
>> >   a=[random.random()]
>> >   index =  self.createIndex(row, column, a)
>> >   print "Next two values should be the same"
>> >   returned = index.internalId()
>> >   if returned < 0:
>> >   returned = returned & mask
>> >   print "indexInternalId = ", returned
>> >   print "id(a) = ", id(a)
>> >   print "Forcing to be the same with a 32 bit mask"
>> >   print "indexInternalId = ", index.internalId() & mask
>> >   print "id(a) = ", id(a) & mask
>> >   return index
>> >
>> > if __name__ == "__main__":
>> >   app = qt.QApplication([])
>> >   w = Model()
>> >   w.index(0,0,None)
>>
>> Could you see if the problem goes away if you change
>> qabstractitemmodel.sip
>> so that...
>>
>>QModelIndex createIndex(int arow, int acolumn, int aid) const;
>>
>> ...is replaced by...
>>
>>QModelIndex createIndex(int arow, int acolumn, quint32 aid) const;
>>
>
> I applied this change to the 20090601 snapshot. Executive summary: when I
> check different data types, I can still find places where the two id's do
> not agree. I find disagreement with the mask applied and without:
>
> When I run the script I posted, I get output like:
>
> Next two values should be the same
> indexInternalId =  1849945336
> id(a) =  139691366280440
>
> If I apply Armando's mask, I get:
>
> Next two values should be the same
> indexInternalId =  12719168
> id(a) =  12719168
>
> If I remove the mask and instead do "a=[numpy.uint32(random.random())]", I
> get ouput like:
>
> Next two values should be the same
> indexInternalId =  12719168
> id(a) =  12719168
>
> Still without the mask, if I do "a=[numpy.int64(random.random())]":
>
> Next two values should be the same
> indexInternalId =  12719168
> id(a) =  12719168
>
> And finally, with Armando's mask and with
> "a=[numpy.int64(random.random())]":
>
> Next two values should be the same
> indexInternalId =  110072896
> id(a) =  139754050917440
>

There was a bug report, it has been marked "won't fix":
http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=204226
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Darren Dale
On Wed, Jun 3, 2009 at 12:08 PM, Phil Thompson
wrote:

> On Wed, 03 Jun 2009 17:37:29 +0200, "V. Armando Solé" 
> wrote:
> > Hello,
> >
> > The problem can be solved as shown below.
> >
> > It seems the linux 32 bit implementation gets confused in
> > createIndex(row, column, a) when a is not an integer but a long. With
> > small values of a (10, 100, 1000),  the indexId() method returns the
> > supplied value.
> >
> > The solution is to call createIndex(row, column, a) with a being a
> > python object and not its id. The indexId() method can be masked with a
> > 32 bit mask if it returns a negative value. I have only found that
> > misbehavior under linux 32bit. Windows XP and linux 64-bit behave
> properly.
> >
> > Thanks for your time,
> >
> > Armando
> >
> > import PyQt4.Qt as qt
> > import random
> > import sys
> >
> > mask = 0x
> >
> > class Model(qt.QAbstractItemModel):
> >   def index(self, row, column, parent):
> >   a=[random.random()]
> >   index =  self.createIndex(row, column, a)
> >   print "Next two values should be the same"
> >   returned = index.internalId()
> >   if returned < 0:
> >   returned = returned & mask
> >   print "indexInternalId = ", returned
> >   print "id(a) = ", id(a)
> >   print "Forcing to be the same with a 32 bit mask"
> >   print "indexInternalId = ", index.internalId() & mask
> >   print "id(a) = ", id(a) & mask
> >   return index
> >
> > if __name__ == "__main__":
> >   app = qt.QApplication([])
> >   w = Model()
> >   w.index(0,0,None)
>
> Could you see if the problem goes away if you change qabstractitemmodel.sip
> so that...
>
>QModelIndex createIndex(int arow, int acolumn, int aid) const;
>
> ...is replaced by...
>
>QModelIndex createIndex(int arow, int acolumn, quint32 aid) const;
>

I applied this change to the 20090601 snapshot. Executive summary: when I
check different data types, I can still find places where the two id's do
not agree. I find disagreement with the mask applied and without:

When I run the script I posted, I get output like:

Next two values should be the same
indexInternalId =  1849945336
id(a) =  139691366280440

If I apply Armando's mask, I get:

Next two values should be the same
indexInternalId =  12719168
id(a) =  12719168

If I remove the mask and instead do "a=[numpy.uint32(random.random())]", I
get ouput like:

Next two values should be the same
indexInternalId =  12719168
id(a) =  12719168

Still without the mask, if I do "a=[numpy.int64(random.random())]":

Next two values should be the same
indexInternalId =  12719168
id(a) =  12719168

And finally, with Armando's mask and with
"a=[numpy.int64(random.random())]":

Next two values should be the same
indexInternalId =  110072896
id(a) =  139754050917440

Darren
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] QAction menu questions

2009-06-03 Thread Scott Frankel


Hello David & Darryl,


On Jun 3, 2009, at 7:22 AM, dbod...@trolltech.com wrote:


On Wed Jun 3 13:28:15 BST 2009, Darryl Wallace wrote:

Is there an example someone could point me to that demonstrates  
how to
specify the About Menu and item name, changing them from "Python"  
and

"About Python to "MyApp" and "About MyApp?"


I run your script and the window title says "Menu Test" and under the
help I have "About My App" and "About Qt" and I've attached the
screenshot for proof :)

What operating system are you running in?


I'm developing in OSX.



This looks like a Mac-specific issue.


I was afraid of that.  I'll try the app bundle approach.

Thanks!
Scott




Scott, you could try making an application bundle of your  
application. This
would let you supply the name of the application in the Info.plist  
file.


Alternatively, if you don't know about bundles, you could changing  
the list
of arguments passed to QApplication. Some experiments on X11 didn't  
convince

me that it would work, but maybe it will do the trick on Mac OS X.

David
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt









___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Phil Thompson
On Wed, 03 Jun 2009 17:37:29 +0200, "V. Armando Solé" 
wrote:
> Hello,
> 
> The problem can be solved as shown below.
> 
> It seems the linux 32 bit implementation gets confused in 
> createIndex(row, column, a) when a is not an integer but a long. With 
> small values of a (10, 100, 1000),  the indexId() method returns the 
> supplied value.
> 
> The solution is to call createIndex(row, column, a) with a being a 
> python object and not its id. The indexId() method can be masked with a 
> 32 bit mask if it returns a negative value. I have only found that 
> misbehavior under linux 32bit. Windows XP and linux 64-bit behave
properly.
> 
> Thanks for your time,
> 
> Armando
> 
> import PyQt4.Qt as qt
> import random
> import sys
> 
> mask = 0x
> 
> class Model(qt.QAbstractItemModel):
>   def index(self, row, column, parent):
>   a=[random.random()]
>   index =  self.createIndex(row, column, a)
>   print "Next two values should be the same"
>   returned = index.internalId()
>   if returned < 0:
>   returned = returned & mask
>   print "indexInternalId = ", returned
>   print "id(a) = ", id(a)
>   print "Forcing to be the same with a 32 bit mask"
>   print "indexInternalId = ", index.internalId() & mask
>   print "id(a) = ", id(a) & mask
>   return index
> 
> if __name__ == "__main__":
>   app = qt.QApplication([])
>   w = Model()
>   w.index(0,0,None)

Could you see if the problem goes away if you change qabstractitemmodel.sip
so that...

QModelIndex createIndex(int arow, int acolumn, int aid) const;

...is replaced by...

QModelIndex createIndex(int arow, int acolumn, quint32 aid) const;

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread V. Armando Solé

Hello,

The problem can be solved as shown below.

It seems the linux 32 bit implementation gets confused in 
createIndex(row, column, a) when a is not an integer but a long. With 
small values of a (10, 100, 1000),  the indexId() method returns the 
supplied value.


The solution is to call createIndex(row, column, a) with a being a 
python object and not its id. The indexId() method can be masked with a 
32 bit mask if it returns a negative value. I have only found that 
misbehavior under linux 32bit. Windows XP and linux 64-bit behave properly.


Thanks for your time,

Armando

import PyQt4.Qt as qt
import random
import sys

mask = 0x

class Model(qt.QAbstractItemModel):
 def index(self, row, column, parent):
 a=[random.random()]
 index =  self.createIndex(row, column, a)
 print "Next two values should be the same"
 returned = index.internalId()
 if returned < 0:
 returned = returned & mask
 print "indexInternalId = ", returned
 print "id(a) = ", id(a)
 print "Forcing to be the same with a 32 bit mask"
 print "indexInternalId = ", index.internalId() & mask
 print "id(a) = ", id(a) & mask
 return index

if __name__ == "__main__":
 app = qt.QApplication([])
 w = Model()
 w.index(0,0,None)


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread V. Armando Solé

Dear Darren,

There is something weird going on under linux 32 bit.

The code below works fine on windows.

On linux 64 bit, it is fine either after masking the values, either 
supplying a 32-bit masked identifier. That illustrates the fact the 
intended behavior of  internalId() is to return the supplied value.


I cannot get the same values under linux 32-bit either with or without 
masking.


Armando

import PyQt4.Qt as qt
import random
import sys

mask = 0x

class Model(qt.QAbstractItemModel):
 def index(self, row, column, parent):
 a=[random.random()]
 if False:
   index =  self.createIndex(row, column, id(a) & mask)  #This 
forces a 32bit identifier but not OK on 32 bit

 else:
   index =  self.createIndex(row, column, id(a)) #This 
is still OK after masking to 32bit

 print "Next two values should be the same"
 print "indexInternalId = ", index.internalId()
 print "id(a) = ", id(a), "0x%x" % id(a)
 print "Forcing to be the same with a 32 bit mask"
 print "indexInternalId = ", index.internalId() & mask
 print "id(a) = ", id(a) & mask
 return index

if __name__ == "__main__":
 app = qt.QApplication([])
 w = Model()
 w.index(0,0,None)


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Darren Dale
On Wed, Jun 3, 2009 at 10:37 AM, Darren Dale  wrote:

>
>
> On Wed, Jun 3, 2009 at 10:23 AM, "V. Armando Solé"  wrote:
>
>> Darren Dale wrote:
>>
>>> Hi Armando,
>>>
>>> Relatedly, I think there is a small problem with the PyQt4 documentation
>>> for the overloaded QAbstractItemModel.createIndex method. It looks like Qt's
>>> documentation for passing a pointer is being presented in PyQt4's method for
>>> passing an identifier, and PyQt's pointer method documentation is empty.
>>>
>>> When I first read PyQt's documentation for this method, there was nothing
>>> to indicate that the id passed to createIndex should end up as the index's
>>> internalId(), so I wrote a workaround. But now that I read Qt-4.5's
>>> documenation for this method, it seems clear that these identifiers should
>>> be equal.
>>>
>>> By the way, is your windows machine 32 or 64 bit?
>>>
>> 32-bit. Anyways there is something weird. I have tried masking id and
>> internalId with the operation & 0x in order to generate the same
>> values. Nevertheless, the self._idMap dictionnary keeps growing. I always
>> end up with an infinite tree in linux-32 and not in linux-64.
>>
>> By the way, does the posted code behaves properly on your system?
>> Sometimes fails even at 64 bit.
>
>
> When I run this version of your script, the two identifiers are never the
> same:
>
> import PyQt4.Qt as qt
>
> import random
>
> class Model(qt.QAbstractItemModel):
>   def index(self, row, column, parent):
>   a=[random.random()]
>   index =  self.createIndex(row, column, id(a))
>   print "Next two values should be the same"
>   print "indexInternalId = ", index.internalId()
>   print "id(a) = ", id(a)
>   return index
>
> if __name__ == "__main__":
>   app = qt.QApplication([])
>   w = Model()
>   w.index(0,0,None)
>

I should have noted, I'm testing on 64-bit linux.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Darren Dale
On Wed, Jun 3, 2009 at 10:23 AM, "V. Armando Solé"  wrote:

> Darren Dale wrote:
>
>> Hi Armando,
>>
>> Relatedly, I think there is a small problem with the PyQt4 documentation
>> for the overloaded QAbstractItemModel.createIndex method. It looks like Qt's
>> documentation for passing a pointer is being presented in PyQt4's method for
>> passing an identifier, and PyQt's pointer method documentation is empty.
>>
>> When I first read PyQt's documentation for this method, there was nothing
>> to indicate that the id passed to createIndex should end up as the index's
>> internalId(), so I wrote a workaround. But now that I read Qt-4.5's
>> documenation for this method, it seems clear that these identifiers should
>> be equal.
>>
>> By the way, is your windows machine 32 or 64 bit?
>>
> 32-bit. Anyways there is something weird. I have tried masking id and
> internalId with the operation & 0x in order to generate the same
> values. Nevertheless, the self._idMap dictionnary keeps growing. I always
> end up with an infinite tree in linux-32 and not in linux-64.
>
> By the way, does the posted code behaves properly on your system? Sometimes
> fails even at 64 bit.


When I run this version of your script, the two identifiers are never the
same:

import PyQt4.Qt as qt

import random

class Model(qt.QAbstractItemModel):
  def index(self, row, column, parent):
  a=[random.random()]
  index =  self.createIndex(row, column, id(a))
  print "Next two values should be the same"
  print "indexInternalId = ", index.internalId()
  print "id(a) = ", id(a)
  return index

if __name__ == "__main__":
  app = qt.QApplication([])
  w = Model()
  w.index(0,0,None)
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Fwd: [PyQt] QAction menu questions

2009-06-03 Thread dboddie
On Wed Jun 3 13:28:15 BST 2009, Darryl Wallace wrote:

> > Is there an example someone could point me to that demonstrates how to
> > specify the About Menu and item name, changing them from "Python" and
> > "About Python to "MyApp" and "About MyApp?"
>
> I run your script and the window title says "Menu Test" and under the
> help I have "About My App" and "About Qt" and I've attached the
> screenshot for proof :)
>
> What operating system are you running in?

This looks like a Mac-specific issue.

Scott, you could try making an application bundle of your application. This
would let you supply the name of the application in the Info.plist file.

Alternatively, if you don't know about bundles, you could changing the list
of arguments passed to QApplication. Some experiments on X11 didn't convince
me that it would work, but maybe it will do the trick on Mac OS X.

David
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Qt or PyQt problem?

2009-06-03 Thread Darren Dale
Hi Armando,

On Wed, Jun 3, 2009 at 9:34 AM, "V. Armando Solé"  wrote:

> Hello,
>
> I think I have fallen into a Qt bug but perhaps I am wrong.
>
> According to the (latest) Qt documentation, QAbstractItemModel.createIndex
> takes a uint32 as the model index internalId, while the internalId() method
> of QModelIndex returns a uint64. I guess my problems are coming from that
> inconsistency.
>
> The problem is illustrated below. On a windows machine and on a 64-bit
> linux machine everything is fine.
>
> On a 32-bit linux machine the given internalId (= id(a) ) and the returned
> internalId are not the same. In fact, one of them is negative.
>
> Both, the linux-32 machine and the windows XP machine are running sip
> 4.7.9, PyQt 4.4.4 and qt 4.4.3
>
> Am I missing some obvious solution to the problem?
>
> Best regards,
>
> Armando
>
> import PyQt4.Qt as qt
>
> class Model(qt.QAbstractItemModel):
>   def index(self, row, column, parent):
>   a=[" Hello World"]
>   index =  self.createIndex(row, column, id(a))
>   print "Next two values should be the same"
>   print "indexInternalId = ", index.internalId()
>   print "id(a) = ", id(a)
>   return index
>
> if __name__ == "__main__":
>   app = qt.QApplication([])
>   w = Model()
>   w.index(0,0,None)
>


Relatedly, I think there is a small problem with the PyQt4 documentation for
the overloaded QAbstractItemModel.createIndex method. It looks like Qt's
documentation for passing a pointer is being presented in PyQt4's method for
passing an identifier, and PyQt's pointer method documentation is empty.

When I first read PyQt's documentation for this method, there was nothing to
indicate that the id passed to createIndex should end up as the index's
internalId(), so I wrote a workaround. But now that I read Qt-4.5's
documenation for this method, it seems clear that these identifiers should
be equal.

By the way, is your windows machine 32 or 64 bit?

Darren
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Qt or PyQt problem?

2009-06-03 Thread V. Armando Solé

Hello,

I think I have fallen into a Qt bug but perhaps I am wrong.

According to the (latest) Qt documentation, 
QAbstractItemModel.createIndex takes a uint32 as the model index 
internalId, while the internalId() method of QModelIndex returns a 
uint64. I guess my problems are coming from that inconsistency.


The problem is illustrated below. On a windows machine and on a 64-bit 
linux machine everything is fine.


On a 32-bit linux machine the given internalId (= id(a) ) and the 
returned internalId are not the same. In fact, one of them is negative.


Both, the linux-32 machine and the windows XP machine are running sip 
4.7.9, PyQt 4.4.4 and qt 4.4.3


Am I missing some obvious solution to the problem?

Best regards,

Armando

import PyQt4.Qt as qt

class Model(qt.QAbstractItemModel):
   def index(self, row, column, parent):
   a=[" Hello World"]
   index =  self.createIndex(row, column, id(a))
   print "Next two values should be the same"
   print "indexInternalId = ", index.internalId()
   print "id(a) = ", id(a)
   return index

if __name__ == "__main__":
   app = qt.QApplication([])
   w = Model()
   w.index(0,0,None)
   



___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: Fwd: [PyQt] QAction menu questions

2009-06-03 Thread Darryl Wallace

Hello,


Is there an example someone could point me to that demonstrates how to 
specify the About Menu and item name, changing them from "Python" and 
"About Python to "MyApp" and "About MyApp?"
I run your script and the window title says "Menu Test" and under the 
help I have "About My App" and "About Qt" and I've attached the 
screenshot for proof :)


What operating system are you running in?

Also, it should say "About MyApp" as the code says:

self.aboutAct = QtGui.QAction(self.tr("&About MyApp"), self)
self.aboutAct.setStatusTip(self.tr("Show the application's About box"))


I'm not sure what your problem could be.

Darryl

<>___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Installing PyQt-win-commercial-4.5-snapshot-20090601

2009-06-03 Thread Phil Thompson
On Wed, 3 Jun 2009 18:51:10 +1000, Peter Georges  wrote:
> When attempting to install the latest PyQt snapshot I get the following 
> error:
> 
>
C:\temp\pyqt\PyQt-win-commercial-4.5-snapshot-20090601>C:\python25\python.exe
> 
> configure.py -p %QMAKESPEC% --bindir=%PYQTDIR%/bin 
> --destdir=%PYQTDIR%/py25 --plugin-destdir=%PYQTDIR%/plugins 
> --sipdir=%SIPDIR%/sip
> 
> *Error: This version of PyQt requires SIP v4.8.0 or later*
> 
> The only problem is I cannot find any SIP snapshot and the latest SIP 
> release is version 4.7.9. Where can I get SIP 4.8.0+ ?

Check the SIP download page in a couple of hours.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Installing PyQt-win-commercial-4.5-snapshot-20090601

2009-06-03 Thread Peter Georges
When attempting to install the latest PyQt snapshot I get the following 
error:


C:\temp\pyqt\PyQt-win-commercial-4.5-snapshot-20090601>C:\python25\python.exe 
configure.py -p %QMAKESPEC% --bindir=%PYQTDIR%/bin 
--destdir=%PYQTDIR%/py25 --plugin-destdir=%PYQTDIR%/plugins 
--sipdir=%SIPDIR%/sip


*Error: This version of PyQt requires SIP v4.8.0 or later*

The only problem is I cannot find any SIP snapshot and the latest SIP 
release is version 4.7.9. Where can I get SIP 4.8.0+ ?


Cheers,
Peter.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt