Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PyQt4 strangeness

Reply
Thread Tools

PyQt4 strangeness

 
 
Tina I
Guest
Posts: n/a
 
      01-23-2007
I'm trying to 'convert' my self from Qt3 to Qt4 (it rocks!) and one
thing seem strange:
With Qt3 I usually did "from qt import *", but this does not seem to
work with Qt4. I have to use "from PyQt4 import QtGui , QtCore" and also
have to use "QtCore.something".

Like when connecting a button:

self.connect(self.ui.testButton, QtCore.SIGNAL("clicked()"),
self.doSomething)

Anyone know why this is? Or am I missing something very basic here? (I'm
still very much a noob I guess)

I'm using the Debian packages by the way.

Thanks
Tina
 
Reply With Quote
 
 
 
 
Jeremy Sanders
Guest
Posts: n/a
 
      01-23-2007
Tina I wrote:

>
> self.connect(self.ui.testButton, QtCore.SIGNAL("clicked()"),
> self.doSomething)
>
> Anyone know why this is? Or am I missing something very basic here? (I'm
> still very much a noob I guess)


If you want to import both you can do something like:

import PyQt4.Qt as Qt

which imports QtCore and QtGui

Jeremy

--
Jeremy Sanders
http://www.jeremysanders.net/
 
Reply With Quote
 
 
 
 
Phil Thompson
Guest
Posts: n/a
 
      01-23-2007
On Tuesday 23 January 2007 10:31 am, Tina I wrote:
> I'm trying to 'convert' my self from Qt3 to Qt4 (it rocks!) and one
> thing seem strange:
> With Qt3 I usually did "from qt import *", but this does not seem to
> work with Qt4. I have to use "from PyQt4 import QtGui , QtCore" and also
> have to use "QtCore.something".
>
> Like when connecting a button:
>
> self.connect(self.ui.testButton, QtCore.SIGNAL("clicked()"),
> self.doSomething)
>
> Anyone know why this is? Or am I missing something very basic here? (I'm
> still very much a noob I guess)
>
> I'm using the Debian packages by the way.


The module structure of PyQt reflects the library structure of Qt. Qt4 has
different libraries to Qt3 so PyQt4 has different modules to PyQt3.

The top level PyQt4 module ensures that PyQt3, PyQt4 (and eventually PyQt5)
can all be installed side by side in the same site-packages directory.

The style of import statement you use is up to you. All of the PyQt4 examples
adopt the style you describe, but you can achieve the equivalent of your
current practice by doing the following instead...

from PyQt4.Qt import *

Phil
 
Reply With Quote
 
Tina I
Guest
Posts: n/a
 
      01-23-2007
Phil Thompson wrote:
> The module structure of PyQt reflects the library structure of Qt. Qt4 has
> different libraries to Qt3 so PyQt4 has different modules to PyQt3.
>
> The top level PyQt4 module ensures that PyQt3, PyQt4 (and eventually PyQt5)
> can all be installed side by side in the same site-packages directory.
>
> The style of import statement you use is up to you. All of the PyQt4 examples
> adopt the style you describe, but you can achieve the equivalent of your
> current practice by doing the following instead...
>
> from PyQt4.Qt import *
>
> Phil

Ah, I see
Thanks for the explanation.

Tina
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PyQt4.__file__ gives PyQt4/__init__.py as value wgw Python 1 08-15-2009 09:58 PM
How do I Color a QTableView row in PyQt4 Mel Python 5 03-13-2007 01:35 AM
My python programs need a GUI, wxPython or PyQt4? hg Python 25 01-26-2007 01:08 AM
models & editors in PyQt4 Skink Python 3 08-30-2006 10:29 PM
Drag and Drop with PyQt4 Harshad Python 2 08-26-2006 11:42 AM



Advertisments