Beijer Electronics (formerly QSI Corporation)
http://www.qsiforums.com/

Screens inheritance
http://www.qsiforums.com/viewtopic.php?f=6&t=3959
Page 1 of 1

Author:  alzverev [ Tue Jul 20, 2010 10:55 am ]
Post subject:  Screens inheritance

Hello.

I am still learning QLarity, came to that language after using of other programming languages like Delphi, C++, C.Net. In all these languages I can create a screen or a (custom) form and then create new one inheriting the interface elements and functionality. Is it possible to do the same here?

Regards,
Alexey.

Author:  Jeremy [ Tue Jul 20, 2010 10:59 am ]
Post subject:  Re: Screens inheritance

Probably not the way you mean.

It is possible to inherit a new object based on the screen object and inherit its properties/methods/behavior. However you do not inherit the children, which is what I suspect you want to do. (e.g. have 5 screens that all have the same layout, including the children).

Can you elaborate a bit more on what you are trying to accomplish and perhaps we can give you some ideas as to the best direction to take.

Author:  alzverev [ Tue Jul 20, 2010 11:11 am ]
Post subject:  Re: Screens inheritance

Jeremy, thanks for a quick reply!

In fact, you answerred to my question. I am creating an application with three completely identical screens differing just with event code, the layout is the same. Screens are quite complex so I wanted to build a custom screen with all elements and with common code and then just to inherit from that screen to add event handlers for buttons and code specific for every screen.

So, as you say it is impossible to create a template with children elements, I have a different approach. I plan to create one screen, add a flag specifying which form is opened, then in screenEnabled() event handler I will change labels according to the flag (if-then-elseif...), and in buttons click event handlers I'll add same code to execute needed set of instructions.

Or, maybe, there is a better approach?

Author:  Jeremy [ Tue Jul 20, 2010 11:17 am ]
Post subject:  Re: Screens inheritance

It is fairly rare that I am in your situation. However, I have been there on occasion. There are two main approaches that I have taken.

One is the approach that you describe (use a single screen to do all the lifting, with some conditional code to handle the differences). This approach works fine.

Another approach, which may or may not be more appropriate (depending on your workspace) would be the following:

Create one screen with all the common stuff on it (like you already have). Now you can create a transparent screen that sits over the top of the first screen. Put objects whose behavior will be different based on context in the transparent sub screens. By using multiple transparent overlay screens and changing which one(s) are enabled, you can vary the screens behavior.

Author:  alzverev [ Tue Jul 20, 2010 11:34 am ]
Post subject:  Re: Screens inheritance

Well... I didn't think about such a trick. So, thank you for the idea and for all your help!

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/