Re: Resizable Frames/Layouts
Did you set a layout for the form itself?
Re: Resizable Frames/Layouts
Consider using a single grid layout.
Re: Resizable Frames/Layouts
I just AddWidget all three things? Then change the Column stuff? Any Examples?
THanks tho.
Re: Resizable Frames/Layouts
Quote:
Originally Posted by
VireX
I just AddWidget all three things? Then change the Column stuff?
Yes.
Quote:
Originally Posted by
VireX
Any Examples?
Code:
setLayout( l );
l->addWidget( _treeView, 0, 0 );
l->addWidget( _textEdit, 1, 0 );
l->addWidget( _tableView, 0, 1, 2, 1 );
Re: Resizable Frames/Layouts
setLayout is for some reason undefined. Maybe because my class is made with qtdesigner and is not an extension of QWidget? Also I changed the addWidget to addLayout.
What about QSplitter?
Since setLayout alone didn't work I did this...
The code in my setupUi() function: (qglMain = QGridLayout*)
Code:
qglMain->addLayout(vboxLayout, 0,0);
qglMain->addLayout(vboxLayout1, 1,0);
qglMain->addLayout(vboxLayout3, 0, 1, 2, 1);
MainWindow->setLayout(qglMain);
However, now it just crashes.
Commenting the setLayout line, still makes it crash.
Re: Resizable Frames/Layouts
What is "qglMain"? setLayout is defined in QWidget class, but we're assuming your widget is a widget :) if you create an ui in Designer, you later wrap it into a class inheriting QWidget (or one of its subclasses). That's the moment to put the above mentioned code. But if you use Designer, then simply click on the form (so that no items are selected) and click on "Lay out in a grid" icon in the toolbar.
Re: Resizable Frames/Layouts
Quote:
Originally Posted by
VireX
Maybe because my class is made with qtdesigner and is not an extension of QWidget?
If you created it with Qt Designer, why do you need to add widgets to it? Can't you just add all of the widgets using Designer?
Also read this very carefully --- it explains how to use the code generated by uic.
Quote:
Originally Posted by
VireX
Also I changed the addWidget to addLayout.
A single QGridLayout is enough in this case. There is no point in having layouts with only one widget inside (except for a top-level layouts). You can do the same using one QVBoxLayout and one QHBoxLayout (see below).
Quote:
Originally Posted by
VireX
What about QSplitter?
You need two splitters. A horizontal one with tree view and text edit and a vertical one with the horizontal spitter and table view.
Quote:
Originally Posted by
VireX
The code in my setupUi() function: (qglMain = QGridLayout*)
You shouldn't touch the code generated by uic.
Re: Resizable Frames/Layouts
I said qglMain = QGridLayout*..
Also I tried your designer trick... But now:
[_]| |
[_]|__|
It looks like it seperated everything into 3 boxes. It looks horrible, because the Treeview on the right is so big. I cannot change the size of the userlist, or any of the grid cells.
Why shouldn't I touch the code of ui, I want to change something I don't want to reopen designer and fix it, because it's something in the code.
Also, I tried the QSplitter approach, (yes I thought of 2 of them too) and then all my stuff just disappeared I couldn't see my results, just a blank window.
The QGridLayout approach, just makes my program crash. And using layouts in Designer sucks, so I like to code the layouts instead it's easier to see.
Re: Resizable Frames/Layouts
Quote:
Originally Posted by
VireX
Also I tried your designer trick... But now:
[_]| |
[_]|__|
It looks like it seperated everything into 3 boxes. It looks horrible, because the Treeview on the right is so big. I cannot change the size of the userlist, or any of the grid cells.
Tweaking the hSizeType, vSizeType, horizontalStretch and verticalStretch properties for each widget should help.
Quote:
Originally Posted by
VireX
Why shouldn't I touch the code of ui,
Because you will loose all changes when you change the .ui file.
Quote:
Originally Posted by
VireX
I want to change something I don't want to reopen designer and fix it, because it's something in the code.
But you are fixing the results, not the causes.
Quote:
Originally Posted by
VireX
Also, I tried the QSplitter approach, (yes I thought of 2 of them too) and then all my stuff just disappeared I couldn't see my results, just a blank window.
What did you do exactly? To add a splitter, you have to select two widgets and click "Lay out ... in Splitter". After you create all the splitters, you have to add a top-level layout.
Quote:
Originally Posted by
VireX
And using layouts in Designer sucks,
No, it doesn't. You just have to learn how to use them.
Quote:
Originally Posted by
VireX
so I like to code the layouts instead it's easier to see.
I think it's easier to see it on a live widget in the Qt Designer.
Re: Resizable Frames/Layouts
Yes you're right, it's easier to see it live. But some things I haven't learned to control yet, like layout, I keep trying to change the damn size on the splitter in Designer and can't do it. It won't let me push the center split to the right. I even tried the sizepolicy :
hSizeType, vSizeType, horizontalStretch and verticalStretch, when you change these nothing happens.
How do I move the splitters (horizontal) middle split to the right by like 200 px?
It keeps cutting off my long Text box at the bottom, and keeps the treeview so huge... Because it fixes the splitter so that it's centered in between both the widgets.
Re: Resizable Frames/Layouts
Quote:
Originally Posted by
VireX
But some things I haven't learned to control yet, like layout,
It doesn't mean something sucks just because you haven't learned to use it.
Quote:
I keep trying to change the damn size on the splitter in Designer and can't do it.
And you won't be able to. You can't control the initial size of the splitter - it'll adjust itself according to the widgets it holds.
Quote:
It won't let me push the center split to the right. I even tried the sizepolicy :
hSizeType, vSizeType, horizontalStretch and verticalStretch, when you change these nothing happens.
Set the horizontalStretch of the left part to the same value as the horizontalStretch of the right part.
Quote:
How do I move the splitters (horizontal) middle split to the right by like 200 px?
By using QSplitter::setSizes() in your code.
Quote:
It keeps cutting off my long Text box at the bottom, and keeps the treeview so huge... Because it fixes the splitter so that it's centered in between both the widgets.
That's what you have size policies for.
1 Attachment(s)
Re: Resizable Frames/Layouts
Is the attached UI more or less what you wanted?
Re: Resizable Frames/Layouts
Almost, the table on the right is on the left, and the small corner box is suppose to be under the big one. It looks good tho.
2 Attachment(s)
Re: Resizable Frames/Layouts
Quote:
Originally Posted by
wysota
It doesn't mean something sucks just because you haven't learned to use it.
No, because some programs have a steeper learning curve than others. They could have made it as simple as making tables in dreamweaver but decided that was not a good idea.
I didn't say it sucked anyway, I said it sucks to make layouts in it, which is true.
Quote:
Originally Posted by
wysota
And you won't be able to. You can't control the initial size of the splitter - it'll adjust itself according to the widgets it holds.
Which is why I said it sucks making layouts.
Quote:
Originally Posted by
wysota
Set the horizontalStretch of the left part to the same value as the horizontalStretch of the right part.
Adjusting horizontal stretch on either splitter 1 or 2, doesn't change a single thing. Neither does adjusting the sizes of the widgets, or adjusting the other sizePolicy values. They're basically useless in my situation. The splitter vertical line in the middle of my splitter 1 (horizontal) will not budge.
Quote:
Originally Posted by
wysota
I thought you said I could do it in designer.
Quote:
Originally Posted by
wysota
That's what you have size policies for.
Which don't work.
Also, listen, the untitled ui you gave me...
Has on one splitter horizontal stretch 1, the rest are 0 on both splitters. I don't understand why 1. And also changing those values doesn't change the layout at all. So I don't believe it controls size at all. Maybe if you tell me what exactly to change on each value to move the
middle split (vertical) to the right in splitter 2 (the total horizontal splitter) by 150 pixels, and the horizontal middle split in splitter 1 (the smaller vertical splitter) up by 100 pixels...
EDIT here:
1 Attachment(s)
Re: Resizable Frames/Layouts
Quote:
Originally Posted by
VireX
I said it sucks to make layouts in it, which is true.
No, it's not :)
Quote:
Which is why I said it sucks making layouts.
The problem is with QSplitter which is a widget, not a layout.
Quote:
Adjusting horizontal stretch on either splitter 1 or 2, doesn't change a single thing.
Adjust the stretch before wrapping widgets into the splitter.
Quote:
Neither does adjusting the sizes of the widgets, or adjusting the other sizePolicy values. They're basically useless in my situation. The splitter vertical line in the middle of my splitter 1 (horizontal) will not budge.
It will, preview or compile the widget and you'll see.
Quote:
I thought you said I could do it in designer.
Yes, but you can't control everything - moving the splitter is one of the things you don't have total control over in Designer. You can adjust the sizes before applying a splitter though and they will hold.
They don't work for you. They work quite fine for me :)
Quote:
Also, listen, the untitled ui you gave me...
Has on one splitter horizontal stretch 1, the rest are 0 on both splitters. I don't understand why 1.
Hmm... AFAIR I set the stretch to "3" on the other widget and based on what I get when I preview the form it works correctly (meaning as if it was set to "3").
Quote:
And also changing those values doesn't change the layout at all.
Splitter is not a layout but a widget. But anyway, you can achieve what you want by breaking the layout and applying the splitter again. I know it shouldn't be that way, it's a flaw, but it works with a little effort - it's only a glitch when displaying in Designer, when you compile the code, it'll work correctly.
Quote:
So I don't believe it controls size at all.
Have you actually tried compiling the code?
Quote:
Maybe if you tell me what exactly to change on each value to move the
middle split (vertical) to the right in splitter 2 (the total horizontal splitter) by 150 pixels, and the horizontal middle split in splitter 1 (the smaller vertical splitter) up by 100 pixels...
I can't give you "per pixel" instructions. Qt doesn't work that way. If you want "per pixel" sizes, use QSplitter::setSizes() from within the subclass when you already know the actual size of the widget. The size is impossible to determine from within Designer - it depends on the font used, etc.
Here is your ui:
Re: Resizable Frames/Layouts
Well that's just amazing; thanks a lot wysota as usual you help everyone a lot.
I'll try and use break layout and horizontal stretch before i apply widgets. Once I apply widgets nothing changes the positions/splits
Also on another note... Is it possible to add a pushbutton as an Item inside the TableWidget? Or should I have used Listview?
Re: Resizable Frames/Layouts
Quote:
Originally Posted by
VireX
Is it possible to add a pushbutton as an Item inside the TableWidget? Or should I have used Listview?
You can use "item/cell widgets" with convenience views and "index widgets" with model-views.
Re: Resizable Frames/Layouts
Quote:
Originally Posted by
VireX
I'll try and use break layout and horizontal stretch before i apply widgets. Once I apply widgets nothing changes the positions/splits
This is related to splitters only! For regular layouts you don't have to break the layout - stretches will take effect immediately regardless of when you change them (before or after applying a layout). The splitter issue is probably caused by the fact that widget size hints are not recalculated in Designer.
Re: Resizable Frames/Layouts
I see... anyway thanks. Now onward to learning about skins :).