Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Binding functions in Qt Designerr
#1
Is it possible to bind functions in Qt designer, or would I have to do that on a separate application? In particular, I want to make it so that clicking on one button will lead to a set of other buttons. Is this something that I'd need to resort to code for or can I do it with the GUI application Qt Designer itself?
Quote
#2
Hello,

I am using Qt Designer (instead of PyQt) and I have created a GUI. I am trying to create my own accounting problem, so now I need to be able to make my GUI do the specific functions.

For example, the formula for Total Assets is "Liabilities + Equity." Therefore, I want to make the GUI perform this equation when I specify that it is necessary.

Now that I have my GUI, I need to give it the ability to save numerical accounting data, and perform the specified equations necessary, and various other tasks. Can you help me out with this?
Quote
#3
Hi @Mocap good luck with that Designer code. If you ever want to do PyQt rather than Designer code I would be happy to lend you a hand.
Axel_Erfurt likes this post
Quote
#4
(Aug-08-2019, 12:45 PM)Denni Wrote: Hi @Mocap good luck with that Designer code. If you ever want to do PyQt rather than Designer code I would be happy to lend you a hand.

Why don't you like designer code?
Quote
#5
My opinion is
without Qt Designer you learn and understand it better.
Without Qt Designer, you can quickly make changes later.
Quote
#6
First I tip my hat to @Axel_Erfurt comment as it is basically inline with my thoughts on it

But to be specific @Mocap it is like this -- one of the major elements to how pyqt was designed to be used is Layouts -- now while you can use Layouts while developing a GUI in Designer when you are done and you get that mess of code the Designer barfs out you will notice that their is next to no Layouts (and often not a single one) within that code -- instead it uses a sort of static coordinate system which has issues. So in order of issues they are:

1) The Designer does not use the essential Layout system of pyqt in the code it produces
2) The code the Designer produces is extremely ugly and thus hard to debug and maintain
3) The code the Designer produces is filled with inessential items making it unnecessarily complex
4) The code the Designer produces does not use Class encapsulation as it should in conjunction with pyqt
5) Creating bad code with the Designer takes as much time or more time than creating good code without it

Those are my issues with that tool - yes some folks use it but I would argue that ought never be used because that the reason I hear for its use is often simply a case of programmer laziness and inefficiency. Something that could easily be adjusted if the programmer were to be a bit more thoughtful about what they were doing.
Axel_Erfurt likes this post
Quote
#7
You can find many examples on the pyqt5 github page
I also have some projects on my github page and on the gist page
Quote
#8
(Aug-15-2019, 02:54 PM)Denni Wrote: ... you will notice that their is next to no Layouts (and often not a single one) within that code -- instead it uses a sort of static coordinate system which has issues. So in order of issues they are:

1) The Designer does not use the essential Layout system of pyqt in the code it produces
2) The code the Designer produces is extremely ugly and thus hard to debug and maintain
3) The code the Designer produces is filled with inessential items making it unnecessarily complex
4) The code the Designer produces does not use Class encapsulation as it should in conjunction with pyqt
...

While I mostly agree, perhaps you did not use the designer correctly? I mean, it does output layouts, as long as you create them in the first place.
Quote
#9
Actually @Alfalfa I have never used the Designer -- learning to use a tool that produced questionable code when I can -- once I learned the basics -- produce that same code just as quickly and/or quicker manually means that tool does nothing for me -- which has been my experience most of the time with such tools. Note these kind of tools that produce ugly code have been around for a long time in numerous languages -- but thankfully they are fairly easy to spot and when I spot one I generally steer clear of it as in my experience it is often better to produce the code yourself rather than rely on something that creates code that ugly.

Further my experience thus far with what the Designer produces is something newbies cannot use effectively and I have stated before it ought to come with a warning -- not to be used by newbies. Many times they cannot implement the basics because they cannot understand what it is they produced due to how ugly that code is -- heck I have converted over a dozen of those and I find translating them to still be difficult.

Now I had looked at what my predecessor produced using the Designer and I looked at what many others have created using the Designer and my impression of that tool stands -- it produces basically horrible looking code -- however if you have a demonstration of creating a fairly complicated window using the Designer that does not produce horrible looking code -- and that uses the Layout system as it should be used I would be very interested in seeing it. And I would even be willing to alter my stance on it but no one has been able to do that to date and I am not going to waste my time trying to figure out a tool I do not need.
Quote
#10
(Offtopic) Here I made the overall layout using an ui file, which is compiled to python on install. It is a grid layout, with frames inside one another, tabs, merged columns and many littles widgets.. So I find it's easier to just place most of them in the designer.

İmage


Widgets that need subclass are simply stripped off the layout (ie. class Tree here, or class LibraryTree here...)
And then they are added manually to the layout created in QtDesigner;

self.library = library.LibraryTree(self)
self.ui.libraryLayout.insertWidget(1, self.library)
Which gives;

İmage


Of course, once compiled the ui file is a mess, but it is never meant to be read or edited manually. Performance wise it makes no differences, but when I need to add a button somewhere in the layout, it takes only seconds to do so.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [Tkinter] Binding Entry box to <Button-3> created in for loop iconit 5 334 Apr-22-2020, 05:47 AM
Last Post: iconit
  TkInter Binding Buttons ifigazsi 5 297 Apr-06-2020, 08:30 AM
Last Post: ifigazsi
  Making text clickable with binding DT2000 10 614 Apr-02-2020, 10:11 PM
Last Post: DT2000
  [Tkinter] Setting Binding to Entry created with a loop? p_hobbs 1 380 Nov-25-2019, 10:29 AM
Last Post: Larz60+
  Binding functions to Menus in tkinter?? Mocap 1 512 Jul-23-2019, 01:37 AM
Last Post: Larz60+
  [Kivy] Kivy property (in .kv) loses binding to a variable (in .py) j.crater 3 1,965 Aug-14-2018, 12:37 PM
Last Post: buran

Forum Jump:


Users browsing this thread: 1 Guest(s)