Purely in C++ or Designer mode
-
Hi! I think a mixture of both is common. Most forms have pretty static content, so for these using the Designer is the easiest way. On the other hand, if you have forms where the content / layout, number of buttons etc, depend on run-time decisions, you'll use hand-written C++ code.
-
Hi
I use mostly Designer. :)
Even when i need something dynamic,
I design the layout/look in Designer and simply
take the c++ code from setupUI().For me its much easier to visually design with layouts and WYSIWYG
than coding it. For others, it is reversed.Also the promote feature of Creator makes designing with own Widgets very easy and
thereby make Designer useful most of the time. -
I mostly code, but I try to keep the classes small. If a larger ui is required I'll use the designer just to keep the boilerplate code smaller. The designer also lacks certain features I happen to use often in my uis and I don't like to have it half here and half there.
-
@VRonin said in Purely in C++ or Designer mode:
I use 100% hand written code, I find it faster to do than than .ui but it's just because I'm not used to creator. You have to be careful to separate translatable text
same.
I also prefer to have "full" control over my code and keep it to as minimal as required. -
Both for us.
- We use the Designer when the UI is static.
- If the UI needs to be dynamically configured by our XML init file (i.e. a number of spinboxes configurable by the user), we use the designer to add the static widgets, then a layout or a custom container widget. This container widget is implemented and could be designed in C++ or also in Qt Designer.
-
Has to be pointed out that using code only shields you from any issue in uic: https://bugreports.qt.io/browse/QTBUG/component/19443/?selectedTab=com.atlassian.jira.jira-projects-plugin:component-issues-panel
-
@Wieland said in Purely in C++ or Designer mode:
Hi! I think a mixture of both is common. Most forms have pretty static content, so for these using the Designer is the easiest way. On the other hand, if you have forms where the content / layout, number of buttons etc, depend on run-time decisions, you'll use hand-written C++ code.
Hi!
First, what do you mean by pretty static content please?
And Do you generally mean that it depends on the app we want to create? That is, we first consider the means we use to create an app and then we choose hand-writing C++ or Designer? -
@mrjj said in Purely in C++ or Designer mode:
Hi
I use mostly Designer. :)
Even when i need something dynamic,
I design the layout/look in Designer and simply
take the c++ code from setupUI().For me its much easier to visually design with layouts and WYSIWYG
than coding it. For others, it is reversed.Also the promote feature of Creator makes designing with own Widgets very easy and
thereby make Designer useful most of the time.Hi mrjj. :) Thanks.
Please consider the experience I got. I'm studying the formal book on Qt4.x. I'm in chapter 2. The scenario for making programs have been this way:
Using code:
1- Making a .h file
2- Making a C++ file.
3- Making a main.cpp and then running qmake. Now the app can be run.Using Designer:
1- Creating a Form
2- Making a main.cpp (running qmake)
3- Making a .h file
4- Making a .cpp file. Now the app can be run.The difference, to me, is that using Designer needs one more step and also the other steps are more complex than hand-code.
Do you not agree? -
@tomy said in Purely in C++ or Designer mode:
By reading the answers I think I concluded that when we have static contents we had better use Designer. And when we have dynamic contents we should use hand-coding. Is it right?
There is no direct wrong or right. You got opinions/recommendations as answers.
Use whatever you feel comfortable with. If you need quick and functional results there is nothing wrong in using the designer.
IMO you may get a better understanding of the Qt mechanisms when coding directly.
But build your own opinion ;) -
@tomy
Hi
You can make a full running app very easy.
No need to add .h or .cpp by hand.
You get mainwindow.cpp /h and main.cpp
Use "New File or Project" from File
You can also insert new form with class so there is both UI , cpp and h.
So adding it by hand is by far more time consuming for me. :)
But yes, if you app is so small that creating the interface in main.cpp seems the
best way, then Creator might be overkill.If you plan on multiple forms ( windows ) and a more complex setup then
Creator might become more useful.Also, even if you use UI files, its not something really different from code since it just creates
the c++ code for you.
So if you later, thinks. hey UI is lame. Then its not so hard to use hand written code.There is one thing to consider if you work in teams.
Those on the team not using Qt for interface will have to know Qt in details to add say a
button in pure code. I actually tested this in small scale and it took lookup in help and
even more help adding the connect. Whereas Dragging it from right side to some place on a
form , right click and select goto slot was far less involving
and allows them to add a button etc to test some backbone function.This is often called Anecdotal evidence and its not meant as truth about
how it works for other teams but for us its a huge bonus that
it is WYSIWYG and not heaps of code.as @raven-worx says, its good learning doing by hand! And since you cannot do everything in Creator
there will be code too along the way.So you should definitely try both and see what feels best to you.
Both are valid approaches and there is nothing you can do in Creator that code can't so
nothing to lose :) -
@mrjj said in Purely in C++ or Designer mode:
There is one thing to consider if you work in teams.
Those on the team not using Qt for interface will have to know Qt in details to add say a
button in pure code. I actually tested this in small scale and it took lookup in help andThis is usually when I end up with lots of .ui in my projects is when I work on teams that don't want to hand code everything.
I agree sometimes it is faster to use the designer, but usually I can put together a UI in code as fast as someone else can in the designer. Then I don't have to worry about coding the parts the designer can't handle since they are already written.
I also type at 115wpm though so that helps when coding easy things like UIs. :) I find it slower to take my hands off the keyboard and use my mouse for things in the designer, especially signals/slots.
But as I get older my typing is slowing down.. I was 120wpm 10 years ago, so maybe in a few more years I'll be in the designer more, lol. My wife even teased me the other day when I scored a 108 on a typing test with a new keyboard I was testing... she's like oh you're getting slow. :P
-
I use both. I started using only C++ because I found using the Designer a little daunting and what I needed was simple. As time went on I learned the ins/outs of designer and now do even the smaller UI components with it. This gives me maintainability over just C++. It is purely a design decision!
As a wish-list item... I would love to see Qt have an XRC-like (wxWidgets) component to create UI at runtime with the .UI files instead of generating code for them. This would make things like branding (when a style sheet just will not do) and testing new components much simpler. *** Food for though ***
-
@Buckwheat I'm not a wxWidgets user but do you mean QUiLoader?
-
Why yes, yes I do mean that! Thank you. I love learning something knew every day!