PDA

View Full Version : Resize TableView to that of parent



Qt::maniac
17th August 2013, 13:14
Hi Everyone, I recently got started with Qt and I'm having an issue with my layout management. In the following code I'd like to have the tableView resize to that of the parent widget. Do I have to put the layout in a QMainWindow or is there some method I can call on QTableView. thanks so much.


#include "acme.h"
#include "dataModel.h"

Ramble::Ramble(){

//create our ui
QWidget parent;

QVBoxLayout* main_window = new QVBoxLayout(&parent);
QHBoxLayout* top_pane = new QHBoxLayout;
QVBoxLayout* bottom_pane = new QVBoxLayout;

QListView* tags = new QListView;
QTextEdit* context_view = new QTextEdit;
QTableView* library = new QTableView;

//pack top and bottom pane
top_pane->addWidget(tags);
top_pane->addWidget(context_view);
bottom_pane->addWidget(library);

//create and populate our database
dataModel* music_data_model = new dataModel(this);
QSqlTableModel* table_model = music_data_model->getDummyData();
library->setModel(table_model);

//set up our layout
main_window->addLayout(top_pane);
main_window->addLayout(bottom_pane);
setLayout(main_window);
}

Ramble::~Ramble(){}

Santosh Reddy
17th August 2013, 13:39
Whats with QListView and QTextEdit? Remove them (don't add them) then QTreeView will take up the complete area (with margin) in parent widget.

Qt::maniac
20th August 2013, 16:31
Whats with QListView and QTextEdit? Remove them (don't add them) then QTreeView will take up the complete area (with margin) in parent widget.

Hi Santosh, sorry for the late reply as I didn't get an email notification about this thread.
Okay, so the ListView and the TextEdit widget are both widgets I need in my application. so the question still stands, is there a way to have the tableview exapand to that of the parent's width?

thanks,


also where is my code? I posted it but I don't see it on the forum??