Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
125 views
in Technique[技术] by (71.8m points)

c++ - How to manage QSplitter in Qt Designer

When I press a button, I bring up a dialog where user select things and press 'Ok' at the end. I want a splitter in this dialog. Left pane will show tree and right will show something else. How do I do that right?

From Qt example itself:

 QSplitter *splitter = new QSplitter(parent);
 QListView *listview = new QListView;
 QTreeView *treeview = new QTreeView;
 QTextEdit *textedit = new QTextEdit;
 splitter->addWidget(listview);
 splitter->addWidget(treeview);
 splitter->addWidget(textedit);

So in this example, splitter is created without any dialog resource. If I have to create this way, that would mean I have to create all my controls in the code as well rather than Qt Creator.

What is the right way to do this when I need other controls on the screen?

question from:https://stackoverflow.com/questions/28309376/how-to-manage-qsplitter-in-qt-designer

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can simply create splitter containing items in Qt Designer :

  1. First place your widgets on your dialog or widget in designer (They should not be in a layout)

  2. Select the widgets that you want to be in a splitter (By holding CTL and clicking on them)

  3. Right click on a selected widget and from Layout menu select Lay Out Horizontally in Splitter or Lay Out Vertically in Splitter.

  4. Now apply a grid layout to the dialog and everything should be OK. You would see something like this in Object Inspector View :

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...