PyQt4 Installation Guide on Fedora14

Before Installation

In order to avoid unexpected errors during installation,be sure to install the packages metioned here.This prevents you encounter the same trouble as me.

yum install python-devel
yum install gcc-c++
yum install qt-devel
yum install qt-config

Download Installation Packages

Aaddress: PyQt4 and SIP

We need to download two files:Pyqt4 and SIP

Compile and Install SIP

Extract the SIP package and cd into the folder.

python configure.py
make && make install

Compile and Install PyQt4

Extarct the PyQt4 package and cd into the folder.

python configure.py -k /usr/lib/qt4/
make
ldconfig
make install

Tips

1.If you get following error message during Pyqt installation,be sure to install qt-devel and qt-config

ERROR:
Make sure you have a working Qt v4 qmake on your
PATH or use -q argument to explicitly specify a working
Qt v4 qmake

2.Or you will get this message

/usr/bin/ld: cannot find -lqpycore
/usr/bin/ld: cannot find -lqpydeclaration
/usr/bin/ld: cannot find -lqpygui
/usr/bin/ld: cannot find -lqpyopengl

Please excute `ldconfig` before make install.

Test Scirpt

After installation,we can use this script to test.

#!/usr/bin/env python
# -*- coding:utf-8-*-
import sys
import from PyQt4.QtGui import *
class TestWidget(QWidget):
    def __init__(self):
        Qwidget.__init__(self,windowTitle=u"A Simple Example for PyQt.")
        self.outputArea=QTextBrowser(self)
        self.helloButton=QPushButton(self,trUtf8("hellow(&s)"),self)
        self.layout().addWidget(self.outputArea)
        self.layout().addWidget(self.helloButton)
        self.helloButton.clicked.connect(self.sayHello)

    def sayHello(self):
        yourName,okay=QInputDialog.getText(self,self,trUtf8("Your name:"),self.trUtf8(b"name"))
        if not okay or yourName==u"":
            self.outputArea.append(self.trUtf8("Hello,new guy!"))
        else:
            self.outputArea.append(self.trUtf8("Hello,<\b>%1<\b>.").arg(yourname))

app=QApplication(sys.argv)
testWidget=TestWidget()
testWidget.show()
sys.exit(app.exec_())
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

You need to delete the '\' in '<\b>'

blog comments powered by Disqus