I have a groupbox which contains text boxes. I want more text boxes with in the same groupbox with out increasing the size of groupbox, If this groupBox has scroll it will be easy to achieve this. How to add scrollbar to Groupbox?
My MFC days are a while ago and a bit rusty, but from what I remember this isn't possible, but you can emulate this by placing a borderless, child dialog within the group box and then place your text boxes onto that.
Related
I'm getting started with Qt and decided to build a full-screen text editor. I want to have a button (button with arrow in screenshot) attached to a QDockWidget which opens and closes it so the button is always visible to the right side of the screen and stay anchored to it when dock is visible or resized.
My current app is a simple fullscreen textEdit set to centeralwidget in Mainwindow.
I haven't found a way to do this yet with layouts or existing addAnchor() functions so any help or direction is appreciated.
You can achieve what you want by using a container for your text edit and the button. A QWidget instance can be used as an "invisible"*** container for other widgets.
So in Qt Designer you add a widget as a central widget of the main-window, inside this widget you add the text edit and the button, then you set a vertical layout for this container widget.
Don't forget to restrict the docking widget to only dock to the right side, you can do that with: dock->setAllowedAreas(Qt::DockWidgetArea::RightDockWidgetArea); //assuming dock is the pointer to your QDockWidget.
In case you want the dockWidget to be able to dock to any side and the button to follow, you can do that too, but it get a little bit more complicated. Basically you need to connect a slot to dockLocationChanged of your dockWidget and based on where it's docked you need to set-up a new layout for the container widget to be vertical or horizontal and the order of the textEdit and the button based on the side the dock happened.
LE:*** you will most likely need to set the margins you want, since both the widget and it's layout can have them and the actual content might have higher spacing than you want.
I want to make a QToolBar have 3 columns of buttons when docked on the left side of the QMainWindow, but have 1 row when docked on the top of the main window. Is this possible?
I have a tried using a QToolBar with a custom layout, but the normal re-size behavior of the QToolBar doesn’t work (doesn’t hide widgets behind an expand button when its too small). The non-working expand button isn’t that big of a deal, but the bigger problem is that the custom layout prevents the main window from being smaller than the toolbar.
I was able to get my desired behavior by putting each row of Tool Buttons in a QHBoxLayout, putting that layout in a empty QWidget, and calling toolBar->addWidget( widget ) for each row. This gives me a grid toolbar when the toolbar is mounted on the left, and single horizontal bar when mounted on the top.
I'm wanting to make something like a tab control, but without visible tabs at the top.
I would prefer to have the tabs selected from a list or tree at the left hand side of the page, something like this...
Selecting the list/tree item at the left changes everything on the right-hand side of the dialog.
I know I could do this by individually showing/hiding all the fields on the RHS, depending on the selected view, but this is unmanageable to design, when there are at least 10 different designs. C++ doesn't let me design groups and make them visible/invisible in one go. I would prefer to design them as totally separate dialog resources, and then bring them in, like a tab control.
I believe Windows Forms has a ContentControl, which is like a tab control without the tabs, which sounds perfect, but MFC doesn't seem to have this.
Is there a way to do this nicely? Or maybe even a 3rd party control to handle it?
In MFC you would do this by making a child modeless dialog for each group. For each dialog turn off the titlebar style and border style and it will blend in to the parent window instead of looking like a dialog. Create all the dialogs, then use ShowWindow to show/hide one at a time.
Minor detail: Put an invisible control (like a group box) on the parent window to serve as a landmark. When you create each dialog use MoveWindow to position and size it on the landmark.
Use window style WS_EX_CONTROLPARENT in the parent window to help with tab key navigation from parent to child.
Yes you can using DIALOG resources. Set the DIALOG Style to Child, Border to None, Title Bar to False. You can then add implementation classes/files for each DIALOG. The dialogs are then inserted/removed to and fro the parent as a child components by setting the containing window as the dialog's parent (i.e., SetParent)
I have an application which has Propertysheet dialog box with PropertyPage and dialogbox has three button at the bottom.
PropertySheet and PropertyPage create using MFC CProperySheet and CpropertyPage.
Dialog box display fine in windows xp but in windows 7 its partially cut three button
Please Help me to resolve this problem
It's probably due to the font size being something other than default size (check the DPI in the Display properties). If you're manually sizing the property sheet you'll need to be aware that the dialog units will be multiplied by a factor to calculate the size for a given DPI.
Let me clarify:
Are you embedding property sheet in a dialog?
If yes:
Is there any reason to do so?
The buttons you mention belong to a dialog or property sheet?
Are you resizing property sheet?
If buttons belong to the dialog are they cut by the bottom of the dialog?
The best if you post a snapshot of the dialog from XP and 7.
I have created a MFC SDI application, and the view is derived from CFormView, so i can put some controls on the dialog. I have put a groupbox at the right side of the dialog and put some other controls inside the groupbox, such as edit box etc.
What i want is the groupbox and the controls inside right aligned with the dialog when i am resizing the view, just like the followingbehavior in C#: set the anchor property of groupbox to be "Right"
The EasySize is what i want