What Qt4 widgets should I use and how to approximate a ribbon-style interface? - user-interface

I am trying to create an interface for my application using Qt Designer. I want it to have a tabbed, ribbon-style set of controls at the top, and a MDI-style area with docked windows which I plan to show and hide depending on which tab of the ribbon is currently selected. I am just beginning with Qt Designer as well as Qt4 itself for that matter so I'm not quite sure how to setup the window, which widgets and layouts should I use etc.
It's quite obvious there should be a QTabWidget at the top, but I'm not sure about the bottom. Should I use a QFrame? A QMdiArea? A dock widget? What layouts can I use to make sure the tab widget has a fixed height, occupies the whole width of the window at all times and the bottom area scales as the window is resized?
I've read in the manual that splitter layouts allow for manual adjustment of the size of the widgets they contain, but I can't drag the box size of a widget after I place them inside a splitter. Thus I'm unable to setup the area below the ribbon. Anyone, help?

You should look into the QMainWindow and check the multiple utilities it can provide you (Toolbar, StatusBar, DockWidgets, CentralWidget, etc...).
The way I understood your case is that you will always have the MDI Area visible, and that the tab bar will only be used to change the dockWidgets. Here's how I would do it.
The centralWidget of the mainWindow would be a QWidget with a QVBoxLayout containing a QTabBar widget first (up) and a QMdiArea under it. The sizes should be handled automatically.
This will allow the user (or you) to dock widgets on the left, bottom, top or right areas of the mainWindow's central widget. Keep pointers to the dockWidgets to be able to move and show/hide them at will.
Hope this helps.

VTK Designer, which is built on Qt, has a Ribbon-ish interface. You might take a look at the source code for reference.

Related

Win32 Dialog box: how to keep all objects in windows centered when resizing

I am building and maintaining a Win32 app using Visual Studio.
I have recently edited the .rc file adding WS_THICKFRAME to my dialog STYLE line for all dialog windows to allow them to be resizable.
My current problem is, when I resize a window, its content remains fixed to the left. How can I make the window's content remain centered when resizing using the border?
Pointing to any relevant documentation on this would also be helpful, as I have not had lucky finding that.
If you only want to reposition (rather than resize) the individual controls, an easy way would be to create a non-modal container dialog to hold the controls, make that dialog a child of the resizable dialog, and then when you handle WM_SIZE for the outer dialog, you only have to reposition that one non-modal dialog.
Your new position is ((newWidth- controlDlgWidth) / 2, (newHeight-controlDlgHeight)/2), where controlDlgWidth, controlDlgHeight are the width and height of the child dialog.
I say to use a non-modal dialog for this, so that you can continue using a resource script, rather than needing to add a whole bunch of explicit CreateWindow() calls.

How to create consistent toolbar buttons with icons

Desired look
I wish to make a toolbar for my app that will contain some simple buttons, each with a single monochromatic icon. Here is an example of some toolbar buttons similar to I'm trying to achieve, from Mail's compose window:
Notice these buttons have a consistent size, inner padding, padding, and shading. This is a pretty consistent style across macOS, present in Mail, Safari, Finder, etc. This leads me to suspect there's a standardized UI component for creating such buttons.
If I use a segmented control, each button looks correct, with each icon being correctly padded:
Now I would like to add individual buttons that match the style.
Attempt 1
My first attempt was to add a "Push Button" (NSButton) to the toolbar:
This resulted in a wide button that's a bit too short, and not lined up with the segmented control:
Attempt 2
My second attempt was to use a segmented control, with only 1 segment.
This resulted in a button that's the right shape, size, etc., but it was off center relative to its label.
Naturally, I can manually adjust the button to match the goal, but I feel like I'm missing something. What's the proper way to create these standard buttons?
This is actually quite easy to do and you were close already.
You can use NSButton for that. Note that it has different styles (defined in NSButton.BezelStyle) to choose from. The default one is the one to use inside windows and modals. But for toolbars, to match the style of segmented controls and search bars, you can choose the style .texturedRounded.
You can also set the style via Interface Builder. Note that you have to select the button itself, not the toolbar item around it.
To get the correct size, you seem to set the icon within the toolbar item, not the button itself.
Here is my result:

How to perfectly mimic toolbar buttons as in Finder, Safari, or other default apps?

I'm trying to create an application that would be as standard as possible in terms of style.
An image is worth a thousand words: I can't figure out how to make my buttons the same size as in Apple's programs such as Safari or Finder.
As you can see, the sizing I've set in interface builder don't seem to match the size the buttons get when I run the app, but maybe that part doesn't speak in pixels but in points or something? Also, textured rounded button has only width editable, but not height.
In this case, these are NSButtons, but I guess I'll have a similar problem with other control types...
I found it out! The problem was with neither of these two parts outlined in the screenshot, but in the "Toolbar" item, higher in the hierarchy.
There is a Size attribute in the Attributes inspector which defaults to Small, but you can set it to Regular instead, and then the buttons get the same sizing as in Finder and all.

Need guidelines for developing GUI builder tool using ruby-gtk2

I am in process of developing custom GUI generator tool (its new GUI tool like glade) and to achieve that i am using ruby-gtk2. I am a newbie to the world of ruby and gtk, so i need a help in a problem which i am struck regarding adding background image to a widget.
Let me explain in detail, the application (i.e.,GTK::window) has two sections say left section and right section (section can be frames,layouts,panned window or equivalent). Left section has a list of all widgets like Button, Label, CheckBox and so on as images. So user who needs to design the GUI will drag and drop any widgets from left section to right sections, on dropping to right section it (i.e., widget) should be re-sizable and also draggable across right section.
Currently i am adding all widgets to eventbox so that on drag n drop on right section i will get all the controls of events like drag_start, drag_motion, drag_end etc..But how can i add an image as background to eventbox, so that i have button image added to eventbox and also handle resize and drag. Concept is user should be able to resize the properties of widget that drops to right section. Need help in implementing this, i know i am missing something to achieve this. Awaiting any suggestions.

qt - creator - how to maximize the widget screen

I am tryimng to make a UI. But in qt, the window size is too short, I want to work in a separate windows like photoshop. Here I am posting the picture. I want to see the middle window(i rounded it by rose color) in full screen size. Can anybody help me?
EDIT:
If I want to create a full screen application, How can I position the widgets in it. It's possible dragging a widget inside a scroll bared window,but is not user friendly. I want it to work like photoshop, like separate windows.
If you want to have more space to work on the design of your widgets, you can open QtDesigner separately and maximize the design area. Panels can be closed and undocked.
Now if you want to maximized only the central widget, there is a trick:
Create a custom widget and work on it in QtDesigner. You will be able to put it in near full screen by increasing its size
Set your custom widget as central widget in your GUI application.
Previous answer before edit:
Hi, If you want to view your widget in fullsreen mode, you can call the ShowFullScreen function. If what you want is to maximize the widget, you can call the ShowMaximized function.

Resources