How to use custom widget in Qt-Designer - qt

I want to use a custom widget in the GUI-Designer of Qt-Creator IDE.
So i created a class which inherits from Qt's QWidget. It worked to place
it on a QMainWindow programaticaly, but have to do my work in the desiger
where it does not appear as an option in the kist of components.
I googled to find a solution for problem an found an manual on, who guesses, the
Qt doc page ( https://doc.qt.io/archives/qt-4.7/designer-creating-custom-widgets.html
and https://doc.qt.io/archives/qt-4.7/designer-creating-custom-widgets.html).
I tried to follow it but doesn't work.
Does someone know an other way to do this or can give a hint where i can search
for problems following this tutorial?
Thanks in advance.
Codierknecht

There is a different example in the examples section of the Qt documentation that I think is a lot clearer.
Custom Widget Plugin Example
It was a little unclear to me when reading the tutorial where the Q_EXPORT_PLUGIN2() macro goes, but having full example code and project alleviates that.

If you are like me, the analog clock example didn't do it for you, in which case I found just one better tutorial. It may be on the kde site but I you dont need kde to do it, it just explains how to make the custom widget a plugin so you can add it into Qt Designer, rather than having to code it in, which is the norm when you just add a widget to your project and customize the class. I hope this page helps you like it helped me, get in the right direction of writing a single Qt Designer (or multiple) plugin:
Writing Qt Designer Plugins
If this link ever becomes dead, just do a search for the link itself, usually that will turn up the original page in someone's cache, as they do in the other examples above (the dead links in the above answers that just take you to main area and not to the pages originally intended).

Related

Treeview for FileSystem with checkboxes in qt

We need a tree view with File system and check boxes in QT. Is there any way to achieve that?
The tree we need would look something like below:
UPDATE:
I am able to achieve it with subclass of QFileSystemModel. Still have few challenges, but at least subclass is working. Below is the code if anyone needs it. Below is the link to the code -
https://drive.google.com/file/d/1qViZ3iEW2pV2th0jQhzneDL14SEhIgS0/view?usp=sharing
The pending work is to apply a wait cursor (or make treeview uneditable when the check/uncheck is taking place).
PS: It will take a lot of time if root node is checked.
Well, all of that can be achieved with minimal customizations of built-in classes, actually those checkboxes is almost the only thing that has to be done yourself.
QFileSystemModel already provides a proper model for displaying the current filesystem contents, it can be subclassed
As for QML, the best demo is already provided by Qt, check the File System Browser Example. This example uses some deprecaded Qt functionality, but still it shows the basic concept.
The modern techniqes can be also found in the answers to the following question: Qt File Browser based on QML
Hopefully, all that helps you, good luck!

Is it possible to create a Qt customer widget *in* designer *for* designer?

I have found a really neat custom widget for Qt and managed to incorporate it into Qt Designer. I would now like to create a customer widget in designer by placing 32 of these LEDs into a new widget in Designer, then add some functions to it such as giving it address and passing data into it that will then illuminate patterns in colours according to the passed data.
My questions are:
Can I do this? I have placed 32 LEDs on to a new QFrame widget in designer and named the LEDs 0-31, but am at a loss as to know what to do next.
Is there a tutorial anywhere for this? I have found loads of hits on google for creating custom widgets for designer, but not using designer.
Please bear in mind I am not a good Qt programmer, I write embedded code for micros in C and am really not good at object orientated code; I can just hack together relatively simple programs for test and measurement. I need something that will hand hold me through this.
http://doc.qt.io/qt-5/qtdesigner-worldtimeclockplugin-example.html
This seemed to be the kind of thing I wanted, it seemed to look like someone has placed widgets on a screen to create a new widget, but it seems to keep referring back to Creator.
Maybe I am trying to do something impossible. Maybe I have to place this new LED in creator with code?
Many thanks for any pointers.
Yes, it is. A Designer plugin basically consists of 2 Parts:
The Widget that you want to add to the designer
The plugin itself that provides information about the widget usw.
You can simply create the widget with the designer, add the QDESIGNER_WIDGET_EXPORT macro and thats it. Create your designer plugin to load this widget and it should work.
Note: Since you mentioned your not very experienced, you should try to follow the Custom Widget Plugin Example. Once you understood that one, it's only a small step to your designed plugin.

How do I use my own custom buttons and design with wxpython

I've been looking for some inspiration with wxpython as far as the GUI goes. Everything in the demo looks boring and uninspiring so I want to go in my own direction but I can't figure out how to use my own buttons I made in photoshop or my own background images.
I'm kind of new to GUI programming so I ask if you could please be clear in what steps I should take. Once I intialize the frame...how to I load my custom buttons, or set the panel background?
As acattle pointed out, I already wrote on how to change a panel's background. You should note that wxPython isn't a themable GUI toolkit. It uses the native widgets of the OS wherever possible and most of the time, those just aren't very themable. If you need that, then you should look at Tkinter's (especially ttk) or pyside/pyQt.
If you need bitmap buttons, there are several options:
BitmapButton
GradientButton
AquaButton
PlateButton
I did some googling and I found this tutorial for setting the background of panels.
A bit more googling and I found this post talking about wxPython's Bitmap Button Class and showing some code examples.
I would suggest being very very careful designing your GUI if you're going to use custom images. You need to pay special attention to your spacing and your text sizes or your GUI might come out looking like crap.

Is there a Flex widget for a common calculator?

I need a calculator for a flex app I am making, and was wondering if there was any official widget prebuilt or already in good quality. I could make one myself but it would be nice to use one that already existed and had a nice api to customize it with. Any ideas? Thanks!
Not official or anything, but you should check out this one.
Yottabyte Calculator
Source code is here.

Hierarchy in Qt [C++]

Guys could any one point it out to me a link to web page where I can find a hierarchy of classes in Qt, preferably as a diagram (something in UML style)? I'm just starting to learn it and I'm finding it quite difficult to work with all these classes - well, mainly with widgets and layouts at the moment- without knowing where they belong.
Thank you.
The official class hierarchy is found here:
http://doc.qt.io/qt-4.8/hierarchy.html
There are also some class charts. It is really big, you need a plotter to print this in a size which is readable:
http://doc.qt.digia.com/extras/qt43-class-chart.pdf
I was looking for the same thing but for QT 5.3. If anyone is interested here you have the class hierarchy for last QT version.
http://qt-project.org/doc/qt-5/hierarchy.html
Unfortunately, the classes diagram does not exist as it is mention here.

Resources