QTableView Splitter and pictures
Hello,
I'm fresh to qt and to linus, I like it.
What I would like is a form, it already has a mainmenu, that contain two things, a QTableView (showing a mysql database, that part is already working) and some container for some jpeg's, and these two divided by a splitter. Something like:
[tableview]
[--splitter--]
[jpg jpg jpg]
I would like to know how to do this with the designer to get more aquainted with it but I also wouldn't mind other help, ie code. Because I'm new it's still kind of overwhelming trying to get some work done.
Thanks, Jean.
Re: QTableView Splitter and pictures
You can't add a splitter in designer.
It is better to do it in code - there's no way better to learn.
For an example:
Code:
...
splitter->addWidget(table);
...
splitter->addWidget(label);
//next, add the splitter to some container widget.
You can find a lot more examples in the Qt Demos. Just browse around...
Re: QTableView Splitter and pictures
Thanks Marcel
I followed your advice but have not much luck yet, I'm brand new you know.
You said : //next, add the splitter to some container widget.
Can you give an example?
I thought that splitter already has a parent in it's constructor.
The form now comes up with the view and the label only a few pixels in size.
This is my code so far
Code:
model->setTable("pix");
model->select();
table->setModel(model);
table->show();
split->addWidget(table);
split->addWidget(label);
Thanks, Jean.
Re: QTableView Splitter and pictures
Quote:
You said : //next, add the splitter to some container widget.
I was meaning a layout, in case you have one. If the splitter is the central widget of your window then you do not need this step.
Quote:
The form now comes up with the view and the label only a few pixels in size.
This is because your splitter has no layout manager to handle its size and position.
Either set the splitter as the central widget of your main window or if you use a QDialog instead, then set a QHorizontalLayout as the dialog's layout and use layout->addWidget(splitter), causing it to resize to the full client area of the dialog.
EDIT: if you want more control over the splitter's widget sizes the I suggest using QSplitter::setSizes() or QSplitter::setStretchFactor().
Re: QTableView Splitter and pictures
Thanks Marcel,
I'm looking at QSplitter::setSizes()
I could maybe use screenheight returned from the desktop class to set heights..
but..
I was wandering how to do this:
Quote:
Originally Posted by
marcel
Either set the splitter as the central widget of your main window
I hopefully tried
split = centralwidget;
But that is wrong :)
Re: QTableView Splitter and pictures
If you have a QMainWindow in your application then you should use, in one of the main window's members:
Code:
setCentralWidget(splitter);
You should browse through the Qt examples. You can find a lot of useful stuff there, including splitters and main windows.
Re: QTableView Splitter and pictures
He Marcel,
I gave up on the splitter for now, as this is my first linux/qt project I thought i'd better start with something more modest, also because I want to learn the designer.
Thanks for the help,.
Re: QTableView Splitter and pictures
Quote:
Originally Posted by
JeanC
I gave up on the splitter for now, as this is my first linux/qt project I thought i'd better start with something more modest, also because I want to learn the designer.
Designer is just a tool. There is nothing you can do in Designer that you can't do in code.
So my suggestion is to start browsing the examples and look at their sources. This is the only way you can learn.
Playing with designer now will lead you nowhere.
1 Attachment(s)
Re: QTableView Splitter and pictures
Quote:
Originally Posted by
marcel
You can't add a splitter in designer.
Sure you can. It's in the layouts section of icons.
Re: QTableView Splitter and pictures
I understand and you are probably right in terms of learning proces. Still I like to play with designer a bit, call me pigheaded if you like, but I want to be able to use that tool for quick design.
I have located the examples and I am still seeing things for the first time but I am learning and I will probably be on my way in a few days.
Thanks.
Quote:
Originally Posted by
marcel
Designer is just a tool. There is nothing you can do in Designer that you can't do in code.
So my suggestion is to start browsing the examples and look at their sources. This is the only way you can learn.
Playing with designer now will lead you nowhere.