PDA

View Full Version : About Qt designer



HelloDan
24th February 2009, 05:07
Hi friends.

I find the Qt designer is very difficult to use. It's very easy to run out of order. for example, I want to setup a dialog like this:

Three QGroupBox in the leftverticallayout.
two QPushButtons in the rightverticallayout
I want to setup them as a mainlayout. But horizontallayout and gridlayout both fail, their size never meet my thinking.

Do you have any good advises? Thanks

I have attached my ui file.

ComaWhite
24th February 2009, 05:35
What I'd suggest would be to start a new form. drag a grid layout on to the empty form. and right click on the main form. Make sure you have it there. And click layout then go to grid layout and it will make that grid span to the whole form and then start working from there. Then you can simply add them how you like. And when you resize the form it will resize. You can have like say for instance two buttons on row 1. Then on the second row you can add another button and make it span the with of those two buttons. And like with your layout. Just create it normally. When you add the buttons just put them on the side and just stretch the other contents and push a horizontal spacer in.

Oh and if you want on the example. To make the group boxes not expand from top to bottom just at a vertical spacer.

And also like how I said, to make it expand all the widgets when you make the form maximised, just drop a grid onto the form and right click -> layout -> grid. You can do that also in groups, tab controls etc and it's the same process. Just look at the example for help. If you want to know more just ask and me or any other person can help you more =]

HelloDan
24th February 2009, 06:13
Thanks! I will try!

HelloDan
24th February 2009, 07:09
Thanks ComaWhite. Your ui form is very perfect.

But I failed to do it for myself. Can you shoot some photos for me step by step to show me how to make it? For example, how can you make the two buttons in a cell, but mine will be splited into two. And also the QGroupBox, how to configure it.

thanks very much!

HelloDan
24th February 2009, 07:19
At the same time, the two buttons in the same cell as a whole have the same objectname, but they should function different, for example, one OK, and the other Cancel.
how to solve this problem?

If you can help, Please send the photos to sysuor@gmail.com.

Thanks!

HelloDan
24th February 2009, 08:22
I see, it's a buttonBox, but how i can make they receive different signals?

HelloDan
24th February 2009, 08:30
buttonBox = new QDialogButtonBox(QDialogButtonBox::Open
| QDialogButtonBox::Cancel
| QDialogButtonBox::Help);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(openFile()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(help()));


I know how to use them now.

still the problem, how to configure the Groupbox

HelloDan
25th February 2009, 03:47
Hello Friend, Thanks for your help. But I still fail to make my own layout. I don't know how to setup it. I must must one more( two in total) vertical spacer to make my one groupbox to have a comfortable enough space but not a line, while yours is only one can do. Can you give me more tips. Thanks very much!

see the attachment, my own new UI file

stevey
25th February 2009, 05:42
If you want to prevent the boxes from expanding vertically, restrict it with one of the properties, don't use spacers. Is just neater and easier to work with.

HelloDan
25th February 2009, 07:23
If you want to prevent the boxes from expanding vertically, restrict it with one of the properties, don't use spacers. Is just neater and easier to work with.

It's hard to understand. How to do? If I don't add one more spacer, the QGroupBox will be compressed to a line, but it will still add two more cells.

Can anyone help?

ComaWhite
25th February 2009, 09:21
Sorry I didn't respond so quickly issues in RL.

If you wanna do it without spacers. Just edit the minimumSize and maximumSize properties. But I use spacers like crazy ;P. The just resize the form in designer and it will fix. But yeah the spacer at the bottom of the form is forcing everything up. So when you add a new QGroupBox to the form it will make it into a single tiny thing. Just delete the spacer at the bottom and resize the form and when you are done just add another. But I don't recommand spacers because it limits stuff that shouldn't be. Especially when forms are resizeable.

The reason for the splitting of the buttons is because the vertical sizePolicy was set to expanding. instead of fixed. So when you set it to fix it will not grown aka not have the gap between the OK and Cancel button. Oh in that little code you post. If you click on the ButtonBox and look through the properties you can see that you can add more buttons to it that way.

HelloDan
25th February 2009, 09:50
Sorry I didn't respond so quickly issues in RL.

If you wanna do it without spacers. Just edit the minimumSize and maximumSize properties. But I use spacers like crazy ;P. The just resize the form in designer and it will fix. But yeah the spacer at the bottom of the form is forcing everything up. So when you add a new QGroupBox to the form it will make it into a single tiny thing. Just delete the spacer at the bottom and resize the form and when you are done just add another. But I don't recommand spacers because it limits stuff that shouldn't be. Especially when forms are resizeable.

The reason for the splitting of the buttons is because the vertical sizePolicy was set to expanding. instead of fixed. So when you set it to fix it will not grown aka not have the gap between the OK and Cancel button. Oh in that little code you post. If you click on the ButtonBox and look through the properties you can see that you can add more buttons to it that way.

Thanks!

But that is one more problem. Compare with you example, the latter UI file i upload and do the same things with your example, but that is two cell in my Ui file, but your just one with a spacer. How I can merge my two cell into one just as you did.

Thanks again!

ComaWhite
25th February 2009, 17:09
Depending on which one. Just pull on one of the ends that you want it to go into the next column or row and just pull on it and it will span to the next column|row

HelloDan
25th February 2009, 17:13
Depending on which one. Just pull on one of the ends that you want it to go into the next column or row and just pull on it and it will span to the next column|row

Oh, Thanks sincerely! I make it!

ComaWhite
25th February 2009, 17:36
That is good to know ^_^ Good job