473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 2067
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.