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(){}
#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(){}