I have PyQT v.4.8.8 installed.When I draw layouts and I want to view the code , it comes with error that is unable to launch uic as in snapshot:
I can compile the .ui files manually in cmdLine. But I dont know where to put the code for slot,methods ,signals.
1- Where should I set the settings for finding uic to compile ui? My installation does not have pyuic4.
2 - Where can I define my own slots/methods and functoins signatures ? (receiver object,sender) I can see the Edit signals/slots in edit menu but that only shows standard signals/slots.Doesn't have options to define yours.
As the name says, the Qt designer is for interface design only. You cannot use it to write the code for the actual application logic. For this, you'll need a normal Python editor. The exact details on how to use designer files in Python are explained in PyQt reference guide, Using Qt Designer.
Btw, uic is not for PyQt, but for compiling user interfaces into C++. To compile user interfaces to Python, you need to use pyuic4. This tool cannot be run from the designer, you need to run it manually. But it is recommended to load the user interface dynamically at runtime using the PyQt4.uic modules as explained in the reference guide.
I found this tutorial for PyQt4 explaining how to add your own slots in Qt4.Very informative.
Related
I have seen the FAQ https://wiki.qt.io/Qt_for_Python#Frequently_Asked_Questions which states
Take into account that if you want to generate bindings for a Qt/C++
project, the linking to the Qt shared libraries will be missing, and
you will need to do this by hand. We recommend to build PySide2 from
scratch to have everything properly linked.
Suppose you want to use shiboken2 to wrap a c++ library which itself uses qt and it even uses qt classes in its interface. In the python world you should be able to
pip install PySide2 my_cpp_lib
and afterwards python scripts shall be able to
import my_cpp_lib
from PySide2.QtCore import QObject
my_cool_object = QObject()
my_cpp_lib.my_cool_api(my_cool_object)
It is pretty unclear to me how to achieve that setup. From the FAQ I deduce that it would be good to compile PySide2 from source in this case (because I want to use shiboken2_generator to wrap my_cpp_lib). However, I still want to be compatible to the standard PySide2 package (of course there will be a version dependency between my_cpp_lib and PySide2).
Is linking against the QT shared object/dll of PySide2 a bad idea? If so, why? what would be better instead?
If the qt library should be packaged together with the my_cpp_lib python package, then how is it possible to still use PySide without conflicts (because there are essential two different shared objects)?
I have a python application using PySide, Qt and python. In my application I would like to open and display a pdf document, but have the viewer within the application and not using the default viewer on the operating system.
I have not as of yet been able to find a widget which is capable of doing this or some example code. I have never used these tools before and this is my first Qt & PySide application so I am sure there is a widget which is capable of this but that I am just not aware of it.
I found this post and when I take the sample code I am unable to get any pdf to show and cannot replicate the behaviour of the poster, but I am using python 2.7.3, PySide 1.1.1 so perhaps this is why. The error that I get when trying to run the sample code in the other post is:
QWebInspector: QSettings couldn't read configuration setting [resourceTrackingEnabled].
and the pdfs I would like to render are saved locally, in the same directory as the the python script and not accessible via the web.
Could somebody point me in the direction of some sample code or a Qt widget which I would be able to use to render a pdf?
As an aside, I am not sure that it matters but the pdf will be generated using LaTeX.
Edit --More information--
The program has to run on both Windows and Mac OSX environments but it is just for a personal project which wont be distributed. Using PyQt is not an option as it is not compatible with the python editor that I use and PySide is the requirement. I have read the following link but from what I understood under the Rendering section it said that the 3rd party libraries available worked with C, C++ and Qt not python or PySide but maybe I have misunderstood this?
I'm developing a program in python with a gui in pyqt4.
Now i have some porblem with the design of my buttons.
They have some style like windows 98 and i don't like that.
I have change my theme of my raspberry but nothing changed in my python application.
The theme changed my raspberry but not my application.
I use LXDE on my raspberry.
Do have anybody some solution?
Thanks,
You can change style of the Qt Application using one of the built in styles from Qt, for example you can use:
app.setStyle('plastique')
There are QWindowsStyle, QPlastiqueStyle, QCleanlooksStyle, QGtkStyle, QMotifStyle, QCDEStyle...
or you can use QSS (Qt Style Sheets) to theme your application, docs are here: http://qt-project.org/doc/qt-4.8/stylesheet.html
Am working on a pyqt app, done the ui via qt-designer 4.8.1, and generated the corresponding py file using pykdeuic4 (available on OpenSuse 12.2), but can't find an equivalent for pyrcc4 to hadle the *.qrc files.
what's the equivalent tool/command?
Edit:
Most of the documentation on using QtDesigner with PyQt, indicates using pyuic4 / pyuic (which on my platform is pykdeuic4), but as for the other tool pyrcc4 / pyrcc, I can't find an equivalent.
Am wondering, where can I even get the original tool from (pyrcc4)?
There is no PyKDE-specific tool that corresponds with pyrrc4. The KDE python bindings are built on top of PyQt, so you can just use pyrrc4 itself.
PyKDE only needs a specialized tool (pykdeuic4) for compiling ui files, because obviously KDE has lots of widgets that PyQt doesn't know about.
For OpenSuse, I believe the package that contains pyrrc is python-qt4-utils.
NB: The PyKDE project is moribund: see here for details.
Well, turns out all I needed was to install the extra package python-qt4-utils ontop of the existing python-qt4. Now, I have the sought after utilities in place.
I'm new to Qt and Pyside, and confused with lots of dazzling concepts and tools.
Instead of using IDE provided, I prefer to vim.
So I wonder what the generic guideline is. That is to say, what're the QML, Qt Creator, Qt Designer? Do I need to use all of them? And what's the normal workflow?
And at last, there're few tutorials about Qt in python, so can I invoke the Qt C++ docs for help (any big differences between C++ Qt programming and Python one)?
I wrote some PyQt based tutorials after leaving my last job, they can apply to PySide also and have some helpful tips in there too: http://bitesofcode.blogspot.com/
I agree you don't need QML or Qt Creator - but using the Qt Designer for building your interfaces would definitely be the way I would recommend going about it.
I make GUIs in a text editor, right in the Python program. You don't have to use QML, Qt Creator. Just read the Jan Bodnar's PySide tutorial and then you'll be able to figure out the rest by yourself, by looking at PySide or C++ Qt documentation