Yes.
Qt Code:
setLayout( l ); l->addWidget( _treeView, 0, 0 ); l->addWidget( _textEdit, 1, 0 ); l->addWidget( _tableView, 0, 1, 2, 1 );To copy to clipboard, switch view to plain text mode
Yes.
Qt Code:
setLayout( l ); l->addWidget( _treeView, 0, 0 ); l->addWidget( _textEdit, 1, 0 ); l->addWidget( _tableView, 0, 1, 2, 1 );To copy to clipboard, switch view to plain text mode
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*)
Qt Code:
qglMain->addLayout(vboxLayout, 0,0); qglMain->addLayout(vboxLayout1, 1,0); qglMain->addLayout(vboxLayout3, 0, 1, 2, 1); MainWindow->setLayout(qglMain);To copy to clipboard, switch view to plain text mode
However, now it just crashes.
Commenting the setLayout line, still makes it crash.
Last edited by VireX; 18th March 2007 at 01:27.
What is "qglMain"? setLayout is defined in QWidget class, but we're assuming your widget is a widgetif 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.
VireX (18th March 2007)
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.
Last edited by VireX; 18th March 2007 at 01:54.
Tweaking the hSizeType, vSizeType, horizontalStretch and verticalStretch properties for each widget should help.
Because you will loose all changes when you change the .ui file.
But you are fixing the results, not the causes.
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.
No, it doesn't. You just have to learn how to use them.
I think it's easier to see it on a live widget in the Qt Designer.
VireX (18th March 2007)
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.
It doesn't mean something sucks just because you haven't learned to use 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.I keep trying to change the damn size on the splitter in Designer and can't do it.
Set the horizontalStretch of the left part to the same value as the horizontalStretch of the right part.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.
By using QSplitter::setSizes() in your code.How do I move the splitters (horizontal) middle split to the right by like 200 px?
That's what you have size policies for.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.
Is the attached UI more or less what you wanted?
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.
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.
Which is why I said it sucks making layouts.
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.
I thought you said I could do it in designer.
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:
Last edited by VireX; 18th March 2007 at 16:46.
No, it's not
The problem is with QSplitter which is a widget, not a layout.Which is why I said it sucks making layouts.
Adjust the stretch before wrapping widgets into the splitter.Adjusting horizontal stretch on either splitter 1 or 2, doesn't change a single thing.
It will, preview or compile the widget and you'll see.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.
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.I thought you said I could do it in designer.
They don't work for you. They work quite fine for meWhich don't work.
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").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.
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.And also changing those values doesn't change the layout at all.
Have you actually tried compiling the code?So I don't believe it controls size at all.
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.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...
Here is your ui:
Last edited by wysota; 18th March 2007 at 18:15.
VireX (18th March 2007)
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?
Last edited by VireX; 18th March 2007 at 20:45.
You can use "item/cell widgets" with convenience views and "index widgets" with model-views.
J-P Nurmi
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.
I see... anyway thanks. Now onward to learning about skins.
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.
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).
You need two splitters. A horizontal one with tree view and text edit and a vertical one with the horizontal spitter and table view.
You shouldn't touch the code generated by uic.
Bookmarks