Groupbox alignment of title in qt doesn`t work. Why? - c++

I created a simple MainWindow form in Qt 4.8.4 designer, in preview title is placed in top left corner as it should be, but when i use this form in a simple program which writen in Eclipse with QT plugin, the title placed straight at top top center which is not right. When i use ui.groupBox->setAlignment(Qt::AlignRight); or left before show(), nothing happen the title stays at the center. What may cause this? Program is minimalistic and there only group box and nothing else.

Have you tried setting a style sheet to it like this:
ui->groupBox->setStyleSheet("QGroupBox::title {subcontrol-position: right;}");

Related

QT-Creator: How to align center my QWidgets when in full screen?

I know how to set my application to start in full screen by settin gthe following in the main.cpp:
MainWindow w;
w.setWindowState(Qt::WindowMaximized);
w.show();
However, when in full-screen, all my widgets goes into the left-top corner.
How to centralized my widgets when in full screen ?! and alike when minimizing the screen to normal size ?!
(a tutorial will be much helpful too)
You need to use layouts when designing your GUIs.
You can look at the Layout Management page on the Qt documentaion.
Also the following video on layouts might be helpful.
Qt - by default - doesn't do anything with window contents when you re-size it. All widgets'll be exactly the same size as were before, so behavior you describes is perfectly fine.
To force window contents to adjust position and size of your widgets you must associate Layout Manager with container.
The easiest way to do it is to fire up Qt Creator and open desired window with UI desinger. Then right click on the container you want to associate Layout Manager and use layout item from context menu.
I thing those article and examples should help you.

How to activate centralWidget in QT Designer

I was looking at this article
How to make a Qt Widget grow with the window size?
but when i got to the answer I got stuck on "activating" the central widget. I notice an icon with a red circle so I guess that means its disabled. I've been searching the net to try to figure out how to "activate" it but I am not having any luck.
Can someone please help me out?
Have a look at the layout system.
That icon does not mean your QWidget is disabled, that just mean you do not apply a layout on it.
Try to press like Ctrl+1 in order to apply a basic layout. If nothing has changed, you might need to put a QWidget inside the central widget first and then apply the layout.

QT window within window?

I'm setting up a small code editor using QT and following this example. However, i'm curious on how to create windows within windows or widgets within widgets. I'm trying to achieve something similar to these:
http://i.stack.imgur.com/Vn8Ut.png
http://www.hanselman.com/blog/content/binary/Windows-Live-Writer/Download-Visual-Studio-2013-while-your-f_1431E/image_4eb5427c-1ae7-4464-9c26-2282fe8d06c3.png
Is there an example of overlaying widgets like this?
Any alternative soloution for QMessagebox for IOS development (QWidget application only)?
I gave an example of getting another QWidget to be embedded and painted on top of another one. Let me know if you have any questions about how it was done.
The PopUp flag and Qt::Tool options are also relevant.
Be sure to check out: the ToolTip property of a QWidget and the WhatsThis property of QWidget.
http://qt-project.org/doc/qt-5/qwidget.html#toolTip-prop
http://qt-project.org/doc/qt-5/qwidget.html#whatsThis-prop
There are also other ways to make borderless, focusless windows that hover and disappear quickly on command. The Window Flags and Widget Attributes in Qt are very powerful when you are looking to modify Qt Widgets.
When you parent a Widget to another widget, it will draw itself on top of the other. Then you just need to resize and position it properly.
Also subclassing existing widgets can give you more options.
Draw text on scrollbar
Also common Qt::Tools that you will find are QDockWidgets. They are awesome!
Hope that helps.
Take a look at Qt Namespace especially Qt::WA_LayoutOnEntireRect and Qt::WA_StyleSheet. Pass it as a widget attrybutes. The second option looks promising but you have to create style sheet for QWidget.

MFC dock at bottom right

I have a pane in an C++ MFC app that I want to dock bottom right as shown in orange in this image. Currently it is going right across the bottom (red).
see http://screencast.com/t/kSpPhvZkgBGj
This is how the user can do it in VS2008.
http://screencast.com/t/kSpPhvZkgBGj
What position is this called? How can I get the same effect?
It depends on the order the panes are created. I developed a software that even has two interface versions, with completely different layouts.
Outlook Layout:
Ribbon Layout
As you can see in the Outlook layout the 3 panes at top got at the left in the Ribbon layout; and the information bar moved from the top to the bottom.
This got some annoying work to be done. I used CDockablePane entities. Are you using them?

How to add a widget to a qt Tool bar

I have the following problem:
I have added a spinner to my qt Tool Bar, which is located from top to buttom. This works fine. But now I want to order some buttons in a special order, but with mainToolBar->addWidget(button_name) it would be among one other. So how can I solve it? I tried to make a new widget "widget_1" and added some buttons to this widget, but when I write mainToolBar->addWidget(widget_1) nothing appears, only the one slider I have already added. Can anyone help me?
Thanks a lot :)
Well, just forget something.
select the widget and then layout in a form or whatever layouting you prefer.
And that's it. now, the widget will be shown in toolbar. it's because of size
and child widgets position. by layouting, everything will be resized and position
correctly.