hi i want to create a 12 buttons dynamically, 6 button 40x40 pixels and 6 button size 60x60 pixels with two different groups (group 1 contains 6 buttons and group 2 contains 6 buttons) with border.and i want to move groups within the dialog eg : MFC dialog window contains many controls and we can easily move the dialog within the screen. same thing i want move the groups which contains buttons within the dialog.
i have created buttons dynamically in a dialog.but i have no idia how to create groups please help me.
I have no idea what you're talking about. Maybe a picture/sketch would help.
As I understand correctly, by "group" you mean a GroupBox. To create it dynamically you just create a CButton with the BS_GROUPBOX flag.
As for moving all the buttons at the same time, AFAIK this is not possible within the same funcion call; you must move each button/groupbox separately.
Related
I have a grid layout on top of which there are 4 group boxes. When I try to hide one of the QGroupBoxes using groupBox->hide(), the group box is not visible anymore. But the space is retained in the layout (I am not using QSizePolicy to retain the space)
How do I make sure that space is automatically used by the remaining widgets?
In the picture, I have hidden 'Group 2'. I want Group 3 to automatically fill up the space. How do I do this?
In order for the layout to do what you want, its child widgets have to 'behave' correctly.
I.e. if one of your group boxes contains a vertical spacer, it might mess up your layout.
I found that setting a stylesheet to the toplevel widget helps with debugging layout issues:
pWidget->setStyleSheet("border: 1px solid red;");
This will paint a red border around (some) widgets and clarifies who uses which space.
You could try to add a vertical spacer below the third group box to "push" them all upwards. If one of the group boxes is then set to invisible, the others should get pushed up and the space between group box 1 and 3 should disappear.
I am programming a game and I have a tab widget which takes up the majority of the window. I want to use the extra space in the tab bar for buttons. I have the tab widget in a grid layout. To accomplish this, I use the code below in order to remove and add back the button widgets to the desired areas (the solution to someone else's question).
ui->centralLayout->removeWidget(ui->exitButton);
ui->centralLayout->removeWidget(ui->ResizeButton);
ui->centralLayout->addWidget(ui->ResizeButton,0,4, Qt::AlignTop|Qt::AlignRight);
ui->centralLayout->addWidget(ui->exitButton,0,4, Qt::AlignTop|Qt::AlignRight);
This does not work for me; however, because I would like the second widget-- the resize button-- to be just to the left of the exit button. What is occurring is that it instead overlaps the exit button. I simply need to move it 21 pixels to the left and have no idea how!
I tried putting both buttons in a frame and then removing and adding the frame the way I did the buttons. Unfortunately the same functions I used do not exist for the qt frame object.
Here are some pictures of my window.
https://docs.google.com/document/d/17w5USWQcCtb6OdcRShdcYcRjXTcdVpmdrG5TWLX71y8/edit?usp=sharing
you are using void QGridLayout::addWidget(QWidget * widget, int row, int column, Qt::Alignment alignment = 0) overload.
2-nd and 3-rd parameters are row and column of a grid. And you put 2 widgets in the same cell so they are overlaping each other.
I solved my problem. Earlier when I was trying to add them to a frame and reposition it I could not but using a widget as the container for my buttons let me place them the way I was earlier attempting to individually place the buttons.
Is it possible to have QGridLayouts within another QGridLayout? I have been trying to do this using the UI designer, so that I can resize all QGridLayouts uniformly.
This is for an Ultimate-Tic-Tac-Toe game I am creating for fun.
Here, I have nine QGridlayouts. I want to group them together. If I want to expand the boxes, I have to go through each one and expand them. Or I have to copy/paste the first box and make sure they are all aligned again.
I tried selecting all of them and clicking Lay Out in a Grid , but that messes up how they are displayed. Especially the lines that separate the layouts. Am I not doing this correctly?
This just looks weird:
Yes, there is no any problems inserting QGridLayout into another QGridLayout. Here is a demonstration how it can be done in the designer.
Pay attention that there are no any lines when you open the widget in the Preview: they are visible only for design purposes.
Buttons are added to the layouts just to see how they are places in the Preview.
I have a CTreeListCtrl in my MFC application.What I need to do is add a button in a particular column of a node when a particular condition is satisfied(type is changed to reference).
In the image I have edited and added a blue rounded oval to mark the place of desired button.What I want to do is to invoke a dialog on clicking it.But I don't have any clue whether it is possible or not.If yes then pls give me some suggesions.
This is no normal tree control. It is already customized to use multiple columns and I am sure it uses some kid of owner draw. For me it seams more like a list control with tree Features... I know some similar code from Codepproject..
Creating a "real" button (window) isn't wise/good. because it is another window inside the list control...
Change your code to "Draw a button. You can use DrawFrameControl.
Just intercept the left mouse click. Check the range if this area is cliecked. Fire a user defined message to the parent window.
In order to split a window into 2, for example, viewing 2 documents at the same time, we created 2 child windows and a split bar to resize the child windows.
But I have seen many applications which have multiple panels without a split bar. In fact, there is a 'line' between the panels, but I found that they created an extra child window hwndChild1Container which contains the first child window hwndChild1 and the size is a litte wider than hwndChild1, hence there is a bar as we see.
My question is: In order to do the same thing, I don't know which window style I have to use for hwndChild1Container. I don't want hwndChild1Container has a board like the main window, but I need it being resizeable and when the mouse is over the right boarder, the cursor changes the shape like the case for main window. Is there a build-in window style for such child window, or I have to do this manually in the window procedure of hwndChild1Container?
Container does not need any special styles. Just process WM_NCHITTEST for container and return HTBOTTOM for bottom pixels.