I am trying to write a custom widget for the Qt Designer using only Python. I was following a couple of tutorials I found online but none of them were working or anything close to what I would call to be a minimum working example.
So my questions are:
What steps are involved to make a a custom widget appear in the Widget Box of Qt Designer?
If you can spare the time: Please provide a minimum working example (like a widget with a label in it saying "A truly minimal working Qt custom widget example").
Or is it maybe not possible at all to include a custom widget using only python?
There are very few examples available on how to make a custom widget in pyqt. I wrote this article with a working example: Making a Custom Widget in PyQt
Here is the answer to your question #3: How do I use promote to in Qt Designer in pyqt4?
I am using PySide and it works the same way. This method works directly with your Python custom widget code. You do not need to write any separate plugin code.
After you have promoted your custom widget, you can right click on it and add your signals with "Change signals/slots..."
I would recommend putting all you widgets in a YourCostumWidgetsPack.UI file, and then when you load this file in Qt Designer, in addition to the UI you are working. It will load all your custom widget information.
I found this article to be your answer: https://doc.qt.io/archives/qq/qq26-pyqtdesigner.html
But, I haven't been able to install it in Qt Designer though :D
Related
I am currently working on a GUI application using PyQt5 and QtDesigner. As I have to make it multi-platform (at least Ubuntu and W10) I will use the "Fusion" style to make it look similar on both platforms.
I was wondering if one could simply set the QApplication style directly in QtDesigner ? I know that a simple <<.setStyle("Fusion")>> will do the trick in the code, but does it exist within QtDesigner so the lines can be automatically generated ?
I'm trying to learn QtDesigner and how much it can be pushed before going into the code.
No, it is not possible to set the style through Qt Designer.
What Qt Designer does allow is to display the GUI with different styles if you select Form-> Preview -> ...
I'm searching for a tkinter custom widget collection that I can include in a application designer I'm writing in 100% Python but haven't had much luck yet. I figured out a way to do a table for instance, but would like to save myself the work if there's a good implementation out there.
I found a couple of packages for pure Python custom widget creation with a little more searching online. One is Python megawidgets, at pmw.sourceforge.net, which, according to their documentation:
"is a toolkit for building high-level compound widgets in Python using the Tkinter module. It consists of a set of base classes and a library of flexible and extensible megawidgets built on this foundation. These megawidgets include notebooks, comboboxes, selection widgets, panes widgets, scrollable widgets, and dialog windows."
A different approach is writing custom widgets yourself using the Widget Construction Kit, at effbot.org/zone/wck.htm. This provides a base Widget class with primitive drawing methods, such as for borders, text, and colors, along with a basic but complete set of event definitions for binding your event handlers to your custom widgets. It has some good advice on doing animated widgets, such as drag and drop.
If anybody knows of any other packages of widgets or construction toolkit APIs, feel free to post it here. Developers will appreciate having a larger selection in a single location.
I am trying to implement a qToolButton onto the qLineEdit. Basically this toolButton serves something like a file browser.
I did found a few links but I am simply not getting it, for example from here
as I am doing out my UI using the Qt Designer.
I tried using the solution within the link as a guide but I am unable to find such parameters within the software.
As such, was wondering if this can be doable in Qt Designer?
I've been searching the internet far and wide for a tutorial on creating custom items for QListView using PySide. I find some usage using PyQt but I find them really strange to me. I would like to recreate using PySide the appearance of the items of the list shown in this link since I'm creating a desktop version of this web application. Any help/idea/sample code is greatly appreciated.
This question is pretty broad considering that you haven't shared any code. Nonetheless, let me point you to a good resource I found very useful getting into MVC programming in PyQt/PySide:
http://www.yasinuludag.com/blog/?p=98
He touches on ListView here and that may give you a better idea of how you can implement custom models and views.
He uses PySide from my recollection. Either ways, PyQt and PySide code are pretty much identical.
Another approach would be to not use QListView but use a QScrollArea and throw in the list items as widgets inside it. Each widget would be standard Qt widgets with a layout, sub widgets and styled as you need. Check this out for a similar scenario: PyQt: How can I create a custom scroll area?
Hope this helps.
Are there any good PyQt4 custom widgets like at Qt-Apps.org?
I would like to start making PyQt custom widgets but online resources that I find don't seem to be clear
For example, Trolltech's and Zetcode's don't seem to be related in any way at all.
Thanks for any input :)
There should be PyQt examples of all C++ Qt examples in your PyQt4 distribution. I have them here: /usr/share/doc/python-qt4-doc/examples. Theye are quite good for the start. When you understand them, it should also be fairly easy for you to port some C++ examples to PyQt code or turn C++ custom widgets to C++.
online resources about PyQt aren't really that rampant, so any information/projects would be welcomed. Don't hesitate to post links to your upcoming widgets or anything else.
I would be really glad to work on that with you as i'm learning more about pyqt as well.
Are you looking for tutorials on making custom PyQt widgets, or looking for a library of them?
I've been developing a library of reusable custom widgets if that's what you're looking for - at somepoint will be getting to the tutorials, but they aren't there yet.
Check out projexsoftware.com, specifically the ProjexUI framework:
http://dev.projexsoftware.com/projects/projexui
http://docs.projexsoftware.com/sdk-reference/projexui-sdk
In looking at it, I'll need to get some images up there...but there's a Calendar widget, Gantt Chart, View plugin system, Node view, Chart widgets, along with a number of extensions to the base Qt widget classes.
Also the easiest way to see the majority of the widgets is in the Qt Designer - so if you have it setup to work with PyQt plugins, wherever you install the projexui library you can add the /path/to/projexui/designer/build to your PYQTDESIGNERPATH and it'll load designer with our plugins.