PyQt4 strangeness

Discussion in 'Python' started by Tina I, Jan 23, 2007.

  1. Tina I

    Tina I Guest

    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
    Tina I, Jan 23, 2007
    #1
    1. Advertising

  2. 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/
    Jeremy Sanders, Jan 23, 2007
    #2
    1. Advertising

  3. 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
    Phil Thompson, Jan 23, 2007
    #3
  4. Tina I

    Tina I Guest

    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
    Tina I, Jan 23, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Munnki
    Replies:
    2
    Views:
    524
    Munnki
    Dec 18, 2003
  2. Joe
    Replies:
    3
    Views:
    465
  3. Stimp

    CDONTS strangeness

    Stimp, May 17, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    412
    Tarren
    May 17, 2005
  4. Robert M. Gary

    Strangeness with Japanese, XML, Java

    Robert M. Gary, Apr 15, 2005, in forum: Java
    Replies:
    2
    Views:
    447
    Soren Kuula
    Apr 15, 2005
  5. wgw
    Replies:
    1
    Views:
    461
Loading...

Share This Page