 Let's revisit two old friends and no don't worry. We're not gonna spend hours and hours talking about this But I want to drive some subtle points home. Let's take a simple little group box We've worked with this before drag and drop that on here. Let's take another one call that We're gonna call this one options. Let's call this one person Now does it really matter what these are named? There's group box underscore two and group box. Does it really matter? Graphically, they're very different and they look like they're gonna serve very different roles. I want to say very different They're just named different But the end user is gonna look at this and say, okay, so this should contain something about a person where there should be options of some kind So that's what I'm really trying to drive in is your naming conventions And let's actually just drag and drop another one on here. Let's call this food You can see how just by labeling them we have drastically different expectations as an end user Person options food and activities are all different But the other subtle difference here is that this guy group box to options now has two children Whereas this guy does not have any So how do we really get to these nestled children? Well, let's kind of take a peek at that. Let's say label Kind of drag and drop drag and drop Let's add some line edits Add some children in here and let's call this email. Let's call this name And let's give this a different naming convention. I've always used the txt prefix. We'll use le for line edit and let's say le email Or if your friends, it's a layman Anyways bad joke. Sorry and le name actually be la email What it la or Lee getting French and Spanish confused. Anyways, so let's call this the name All right now what we can do is we can grab this guy and Just simply set him into a grid layout We've done this before this is really not rocket science and we can kind of grab him And just sometimes I'm not overly skilled with the mouse and the keyboard here And we could rapidly build this layout and let's drag and drop him here Pretty simple pretty easy Now let's add some checkboxes, and I think we've done something very similar to this before And we're just gonna add four checkboxes in here. Let's grab this guy Let's set that layout and let's call this salad pizza ice cream and chicken And I'm getting hungry just looking at this interface here And let's grab some more. Let's say move these over here So We know what you want to eat now. What do you want to do? You only have so many years if you're lucky to live in this world. What do you want to spend your time doing? Well Netflix, of course Let's see Running Maybe you'd like to paint Maybe you're just a family person And let's go ahead and set the layout on this guy Yeah, we've done something like this before not too super complex But you notice a fundamental difference on some things I'm worried about the naming convention on other things I just don't care. I don't really care that running is checkbox underscore six So when should you care and when should you not care is often a question that comes up? Well, if you're gonna have some sort of what I call a buildable option For example, what type of food I really don't care about the name Because I'm not gonna say hey did they specifically check salad? I don't care What I do cares what foods they want so we have a selectable option of some kind But I do specifically care about their email address for their name And let's kind of just work through this example here. So we're gonna go to slot. We're gonna say accepted Go back here Gonna reject that Take your rejection All right, so let's go back here real simple. We're just gonna bang out some code And we'll say Q message box And we're going to look for the children in a Q group box and let's say Q string Get options Maybe I'm a little challenged today There we go right click refractor and Let's go ahead and add the definition there pretty simple code not doing anything super scientific here And then we're going to just say okay, we've got a group box or I should say a pointer to it Now let's get those selected options. So we'll say Q string Value for each And we're just gonna bang out this code as fast as humanly possible Q object Let's actually call that object And we're gonna do that in the groups children and then we're gonna say Q Checkbox we're gonna do a Q object cast which means we're just gonna convert this or cast it It's like casting a spell That's actually how I explained it to a student one day. They said well, can you explain cast? I said, well, it's like casting a spell, you know your Harry Potter and you're going to Change one thing into another so you're gonna change Voldemort into a snail or something All right, so we've got this and we're gonna say if we don't have a pointer then we're gonna return out Because Q object cast will just return to zero instead of the actual pointer However, if we do we're gonna say if CHK is checked Why is it not liking that? I wonder if my editor is just being stupid. Sometimes it does this. I don't know why So we have CHK CHK. This is a good example of how sometimes the editor just betrays us And I'm just gonna say it is checked value append CHK Once again, it has to be trade to me It's okay, we know what to type and we're just gonna say plus and let's do slash r slash n so we have got our Q check box here And we're gonna say Q object cast Q check box the object. So we're just casting here. We've got some errors Let's go ahead and build this and see if it clears up or if we made a mistake. Nope Non void function get option should return a value. Hmm. So let's return a blank Q string Actually, no, we don't want to do that We're gonna say continue now they think about Because if we return then we're gonna miss all the other value So we're gonna continue so we're gonna jump back over this loop now. We've got this. So let's go ahead and return something So I'm gonna say return Value you see what I mean though by that editor thought that this was not a valid variable, but it absolutely is There we go So really all we're doing is we're saying take the group box go through its children They're gonna be pointers to Q objects. We're going to Q object cast into a Q checkbox if possible if not We're just gonna skip over this iteration Then if it is checked we're going to append the value and then just return the value This is not hard. This is not rocket science But there is fundamentally something I want to go over here and I'm going to just copy and paste a Little bit here not a whole lot. You can see this code is very clear very concise We know exactly what it's doing. We have a Q string called message We're going to append the email is the UI le email text. So we know exactly what we're doing here, right? Let's give this a build everything runs just fine and let's go ahead and Little more copy and paste action Not too much more. I promise Some people don't like it when I copy and paste And we're just gonna do this and we're gonna say me at home.com versus My name Now we have a fundamental problem. We want to be able to get the food and the activities Look at the names of these group boxes group 3 and group 4 So let's get the food here Let's jump in here and let's say we're gonna say get options and we want the UI and And group box 3 is our food. Well, that doesn't really help us a whole lot. Just looking at this code and Then we'll say and let's see group. Well, it's not very friendly group 4 I mean, you can kind of see how it does work. Let's go ahead and show that it actually works We're gonna pen the food No, let's go ahead and append the activities here. So we'll say me at home.com Whatever for a name and let's say I want pizza and ice cream in Netflix and family time So it does actually functionally work We can tell our email our name the foods the activities But just looking at the code. It's ugly. So this is where that delineation really happens between caring and not caring If ever you're going to try to tie something from the UI directly to a variable name That's typically when just me as an example. That's when I'll start naming things and that's when I'll go in here and say GRP food, let's call this GRP activities That's kind of one of the little unhidden unhidden untold things that hides from you They don't really tell you about and then GRP now we've got a fundamental problem where you guessed it The editor has not been rebuilt So let's rebuild this UI has been rebuilt by the editor now. This should actually work So in GRP, there's our food now You can see that the string food is getting it from the group food and we're calling get options So it's a very clear very easy to understand We're not calling some weird group box for instead. We're gonna call group activities And if you look at this you can see that the options itself is actually group box too because I don't care about that So again kind of the fundamental concept we're driving home in this video is that when you're tying a UI element To a variable of some kind that's typically when you want to worry about the naming convention The results absolutely the same so then you may be wondering That's embarrassing when you can't spell your name you may be wondering Who eats salad and chicken and who likes running and painting? Well, I do But more importantly Someone else walking into this code can very easily see that this variable goes to that UI element Where if we named this group underscore 68, it's kind of hard And then they got to go in here and figure out which one it actually is and you can see right off The bat well, they aren't really named right here you could filter it out look for it you can move this around and figure it out, but It's not very user-friendly. So when in doubt again UI element to variable make sure you name it correctly I hope you enjoyed this video. It's part of a larger project out of you to me called acute widgets for beginners with C++ This is a large course with 73 lectures and 17 hours of video footage This course covers everything from what is a widget all the way down to complete example applications using the skills you've learned in this course Sorry, there's no QML in this course. This is strictly cute widgets I will make a QML course later on but this just focus on widgets from a beginner's perspective Even those as a beginner's course you do need to have some fundamental information available You need to know C++ and the cute core libs I do have some courses available out on you to me cute core beginners intermediate advance It's not necessary. You take these courses, but it is highly recommended And as always I'm available out on the void realms Facebook group along with 3,000 other programmers. See you there