Sir_of_bad_coding
3rd February 2013, 14:27
Hello, I have five days of experience with Qt.
I've completed my program for the most part, but there's something I just can't get to work.
I want to place QTableView (which has 6 columns) to the middle of the window.
I've tried layouts but that's apparently not what I want.
I've also tried QTableView's move method but that doesn't work, either.
Here's my latest try:
model = new customTable(999, 6, this);
model->setHorizontalHeaderItem(0, new QStandardItem(tr("Manufacturer")));
model->setHorizontalHeaderItem(1, new QStandardItem(tr("Model")));
model->setHorizontalHeaderItem(2, new QStandardItem(tr("Type")));
model->setHorizontalHeaderItem(3, new QStandardItem(tr("Available")));
model->setHorizontalHeaderItem(4, new QStandardItem(tr("Misc")));
model->setHorizontalHeaderItem(5, new QStandardItem(tr("Cost")));
model->table->setModel(model);
model->table->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
model->table->adjustSize();
model->table->move(QApplication::desktop()->screen()->rect().center() - model->table->rect().center());
setCentralWidget(model->table);
Doesn't work... the table just isn't moved. (customTable is a class I made for my own needs - like custom SLOTs and SIGNALs. etc; it inherits from QStandardItemModel and has a public QTableView *table.)
What do I have in mind?
Well, I want my table to be in the middle (ala Wordpad), with a blue background.
I've tried skimming through a lot of classes and methods, but nothing I've tried so far worked. (I also tried QHBoxLayout, but that's obviously not something I want?)
Thank you in advance... and sorry if the solution is easy, I'm just not experienced enough with Qt.
(I'm using Qt 4.8; C++.)
I've completed my program for the most part, but there's something I just can't get to work.
I want to place QTableView (which has 6 columns) to the middle of the window.
I've tried layouts but that's apparently not what I want.
I've also tried QTableView's move method but that doesn't work, either.
Here's my latest try:
model = new customTable(999, 6, this);
model->setHorizontalHeaderItem(0, new QStandardItem(tr("Manufacturer")));
model->setHorizontalHeaderItem(1, new QStandardItem(tr("Model")));
model->setHorizontalHeaderItem(2, new QStandardItem(tr("Type")));
model->setHorizontalHeaderItem(3, new QStandardItem(tr("Available")));
model->setHorizontalHeaderItem(4, new QStandardItem(tr("Misc")));
model->setHorizontalHeaderItem(5, new QStandardItem(tr("Cost")));
model->table->setModel(model);
model->table->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
model->table->adjustSize();
model->table->move(QApplication::desktop()->screen()->rect().center() - model->table->rect().center());
setCentralWidget(model->table);
Doesn't work... the table just isn't moved. (customTable is a class I made for my own needs - like custom SLOTs and SIGNALs. etc; it inherits from QStandardItemModel and has a public QTableView *table.)
What do I have in mind?
Well, I want my table to be in the middle (ala Wordpad), with a blue background.
I've tried skimming through a lot of classes and methods, but nothing I've tried so far worked. (I also tried QHBoxLayout, but that's obviously not something I want?)
Thank you in advance... and sorry if the solution is easy, I'm just not experienced enough with Qt.
(I'm using Qt 4.8; C++.)