472,779 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

PyQt4 strangeness

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
Jan 23 '07 #1
3 2034
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/
Jan 23 '07 #2
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
Jan 23 '07 #3
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
Jan 23 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Harshad | last post by:
Hi, I'm writing a program using Python 2.4 and PyQt4. The aim is to implement drag and drop from filesystem and display a list of files dragged on to the listWidget. This function will later...
3
by: Skink | last post by:
Hi, I created simple property classes with editing option, but since i'm not too much experienced in PyQt4 i'd like to ask if i handle ColorProperty changing right. Any other Property has its...
25
by: Daniel Jonsson | last post by:
So, I've reached the point where my building pipeline tools actually needs to be used by other people in my company. By this reason I actually need to think about the usability, and I've come to...
2
by: AngelOfDarkness | last post by:
Hi guys, unfortunately I am pretty new to Python and Qt and all that. Well, I managed to successfully program a little stuff for my work (computational neuroscientist... no comment please), using...
5
by: Mel | last post by:
I am currently porting an SQL centered Visual Basic application to run on Linux, Python, and Qt4. Currently I am stumped on changing row colors in the QTableView widget. My test code is based on...
2
by: Pradnyesh Sawant | last post by:
Hello, I have a newly installed ubuntu 6.06 system. I am trying to install pyqt4 on it, but without success. The contents of the /etc/apt/sources.list file are:...
2
by: Glen | last post by:
Hello, I've written a script in python and put together a simple QFrame with a QTextBrowser with Designer. I've translated the C++ into python using puic4. The .py file is called outputWin.py. ...
2
by: Pradnyesh Sawant | last post by:
Hello, I have a pyqt4 code in which i'm trying the signal/slot mechanism. The (stripped) code is as follows: class D(QtCore.QThread): def __init__(self): QtCore.QThread.__init__(self) tpl =...
2
by: jiang.haiyun | last post by:
Hi, I am having some serious problems with PyQT4, when i run pyqt script, I always get 'Segmentation fault'. the script is simple: ====================== %less qttest.py from PyQt4 import...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.