Advise for a Qt programmer

35 views
Skip to first unread message

Aleksei Rusev

unread,
Jan 10, 2021, 11:34:57 PM1/10/21
to fltk.general
Hi guys,

I'm an experienced Qt programmer wanting to try FLTK for my hobby project. 
I'm really struggling with understanding how the layout system works more specifically how to approach building a complex UI. My main concern is that every code I met on the internet positions widgets manually (i.e. specifying x, y, width, hight) and put them into FL_Groups. 
In Qt you never position your widget, the layout system does it for you, you just have to tell it how you want this to be done.
So my question is is this a normal way of writing a UI - by calculating all widgets coordinates manually? (I don't like using builders like FLUID)
Another question - I haven't seen a single example with FL_Pack - which seems to have some automatic positioning. Is deprecated or why wasn't it used in the examples I met?

Maybe someone knows any resources for those coming from Qt?
Thanks!

Robert Arkiletian

unread,
Jan 11, 2021, 2:43:24 AM1/11/21
to fltk.general
I don't have Qt experience. But there is an example program called pack.cxx in the "test" directory in the downloadable source code. 
In addition, most widgets placement args are
x,y,w,h
but when one puts widgets in a pack only the width needs to be specified if one declares the pack type: type(FL_HORIZONTAL) All the other args can be 0. Ex. 0,0,50,0
and alternatively if one sets the pack to  type(FL_VERTICAL) then only the height needs to be set. Again all other args can be 0.   0,0,0,50
Btw, you can also set the spacing for the pack.
In addition, I would recommend looking at the the resizing docs in the newer 1.4 version docs (which also works with 1.3.5)


wea...@gmail.com

unread,
Jan 11, 2021, 2:54:06 AM1/11/21
to fltk.general
Hi

On Monday, January 11, 2021 at 5:34:57 AM UTC+1 hou....@gmail.com wrote:
Hi guys,

I'm an experienced Qt programmer wanting to try FLTK for my hobby project. 
I'm really struggling with understanding how the layout system works more specifically how to approach building a complex UI. My main concern is that every code I met on the internet positions widgets manually (i.e. specifying x, y, width, hight) and put them into FL_Groups. 
Positions are Window relative. If you use containers like FL_Group, then just use that container's x() and y() instead of (0,0) and you're good. Fl_Pack is a good way of automatically organizing your widgets horizontally or vertically. 
In Qt you never position your widget, the layout system does it for you, you just have to tell it how you want this to be done.
Most of the time. In some cases you can break the layout and you can freely position widgets. 
So my question is is this a normal way of writing a UI - by calculating all widgets coordinates manually? (I don't like using builders like FLUID)
Yes. 

imm

unread,
Jan 11, 2021, 4:42:51 AM1/11/21
to general fltk


On Mon, 11 Jan 2021, 04:34 Aleksei Rusev wrote:
Hi guys,

I'm an experienced Qt programmer wanting to try FLTK for my hobby project. 
I'm really struggling with understanding how the layout system works more specifically how to approach building a complex UI.


Many of the things that QT and fltk do are handled differently, so many of the expectations you have from your prior QT work may lead to conceptual problems with using fltk.

Be prepared to be surprised at things that just work differently to what you expect!

(I struggle with QT, for the same reason, but in reverse!)

Also, I can not abide Fl_Pack, I don't like how it positions things.
I much prefer just putting things where I want them!
-- 
Ian
From my Fairphone FP3

janezz55

unread,
Jan 11, 2021, 12:55:09 PM1/11/21
to fltk.general
fltk is for simple, portable GUIs, in general. Of course, it also supports complex guis. But, if you need something really fancy, fltk might not be the thing for you, though, in principle, it supports everything.

lifeatt...@gmail.com

unread,
Jan 11, 2021, 9:30:38 PM1/11/21
to fltk.general
I suggest using one of the "third-party" layout helpers. Coming from a WinForms background with a designer which is IMHO much easier to use, I also struggled with FLTK layout.

An example is  FL_Flex which lets you set up your layout using columns and rows; merely include the class and header in your project. You can have nested FL_Flex groups, so you can set up (e.g.) row-based widgets within a column-based layout. I've also used Erco's Fl_Center and Michael Sweet's SmartGroup [part of flphoto] where useful.

There are probably more out there, I can't find them quickly ...

Aleksei Rusev

unread,
Jan 13, 2021, 12:49:46 AM1/13/21
to fltk.general
After tinkering with it a bit more, I think I finally understand how the layout system works. It's all boils down to FL_Group and FL_Group::resizable(widget). In Qt to crate a compound widget (one that contains N children in a certain user defined layout) - you subclass a widget and put child widget into one of the QLayout variants and set this layout to the widget. In FLTK a compound widget is basically a subclass of FL_Group with this->resizable(child) to make it resizable.
It definitely differs a lot from Qt's one but with some practice I think it'll come naturally. Other benefits of FLTK such as small size and static linking beat Qt for sure.

Thank you all!
Reply all
Reply to author
Forward
0 new messages