473,654 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.somethi ng".

Like when connecting a button:

self.connect(se lf.ui.testButto n, QtCore.SIGNAL(" clicked()"),
self.doSomethin g)

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 2082
Tina I wrote:
>
self.connect(se lf.ui.testButto n, QtCore.SIGNAL(" clicked()"),
self.doSomethin g)

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.somethi ng".

Like when connecting a button:

self.connect(se lf.ui.testButto n, QtCore.SIGNAL(" clicked()"),
self.doSomethin g)

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
6538
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 become part of a software for workflow management. When I run the program, DragEnterEvent works as expected, but the DropEvent does not seem to be working. I'm not an experienced Python hacker, and am unable to trace out any problems with the...
3
3196
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 own editor and their control flow is imho ok. Hovewer i'm not sure about ColorProperty. What i do is: in createEditor(self, parent, option, index) i call QtGui.QColorDialog.getColor() and return None
25
2675
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 the conclusion that I need a GUI. So, which of the two packages should I learn, and which one is easier to pick up? Thanks in advance! Daniel
2
6540
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 a simple graphical interface and binding it to my long existing C library. There was no problem, everything was running fine... ... until I decided to upgrade everything to kubuntu's Edgy and PyQt4. Well, I understood that I need to port my...
5
11684
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 code from the PyQt4 examples and looks like this: *** Start Code *** import sys from PyQt4 import QtCore, QtGui, QtSql
2
2948
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: ******************************************************************************** deb http://in.archive.ubuntu.com/ubuntu/ dapper main restricted universe deb http://in.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse deb...
2
4040
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. My Script and its functions are in cnt.py. Finally, my main is in pball.py which follows here: import sys from PyQt4 import Qt, QtCore from outputWin import * from cnt import *
2
2251
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 = ("Primary", "priSec") print "tpl:", tpl self.emit(QtCore.SIGNAL("setLabel"), tpl)
2
3258
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 QtGui, QtCore import sys
0
8375
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7306
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.