db
20th November 2007, 16:00
I'm creating a simple Dialog which contains a TableView. What I'm having problems with is:
1) getting the TavleView to expand to the size of the model and there by expand the size of the Dialog and
2) getting the TableView to strech as the Dialog box is enlarged.
I used Designer to create the object. I created a Dialog without buttons. Placed a vertical layout in it and place a tableview within the vertical layout. Nothing else.
I use the following code to display it but I can't get the desired effects. I tried the setSizeConstraint (I found in another example) but it just shrinks the TableView. The resize seems to have no affect.
Does anyone have a suggestion? Thanks
#include <QDialog>
#include <QTableView>
#include "ui_View.h"
//-----------------------------------------------------------------------------------
class CViewInputs : public QDialog, public Ui::CView
{
Q_OBJECT
public:
// CViewInputs : class constructor method
CViewInputs(QWidget *parent = 0, CHostIFTools * tools=0);
// ~CViewInputs : class destrcutor method
~CViewInputs();
private slots:
protected:
};
//-----------------------------------------------------------------------------------
CViewInputs::CViewInputs(QWidget *parent)
: QDialog(parent)
{
// create form
setupUi(this);
// setup so that form is removed when closed
setAttribute(Qt::WA_DeleteOnClose);
// vboxLayout->setSizeConstraint(QLayout::SetFixedSize);
// setup model
model.setColumnCount(6);
model.setRowCount(4);
// tableView->resize(500,300);
// add data to model
item = new QStandardItem( "Packet Counter");
model.setItem(0,0,item);
item = new QStandardItem( QString::number(200) );
model.setItem(0,1,item);
item = new QStandardItem( "Packets Missed");
model.setItem(0,2,item);
item = new QStandardItem( QString::number(10) );
model.setItem(0,3,item);
// assign model to view
tableView->setModel( &model );
}
1) getting the TavleView to expand to the size of the model and there by expand the size of the Dialog and
2) getting the TableView to strech as the Dialog box is enlarged.
I used Designer to create the object. I created a Dialog without buttons. Placed a vertical layout in it and place a tableview within the vertical layout. Nothing else.
I use the following code to display it but I can't get the desired effects. I tried the setSizeConstraint (I found in another example) but it just shrinks the TableView. The resize seems to have no affect.
Does anyone have a suggestion? Thanks
#include <QDialog>
#include <QTableView>
#include "ui_View.h"
//-----------------------------------------------------------------------------------
class CViewInputs : public QDialog, public Ui::CView
{
Q_OBJECT
public:
// CViewInputs : class constructor method
CViewInputs(QWidget *parent = 0, CHostIFTools * tools=0);
// ~CViewInputs : class destrcutor method
~CViewInputs();
private slots:
protected:
};
//-----------------------------------------------------------------------------------
CViewInputs::CViewInputs(QWidget *parent)
: QDialog(parent)
{
// create form
setupUi(this);
// setup so that form is removed when closed
setAttribute(Qt::WA_DeleteOnClose);
// vboxLayout->setSizeConstraint(QLayout::SetFixedSize);
// setup model
model.setColumnCount(6);
model.setRowCount(4);
// tableView->resize(500,300);
// add data to model
item = new QStandardItem( "Packet Counter");
model.setItem(0,0,item);
item = new QStandardItem( QString::number(200) );
model.setItem(0,1,item);
item = new QStandardItem( "Packets Missed");
model.setItem(0,2,item);
item = new QStandardItem( QString::number(10) );
model.setItem(0,3,item);
// assign model to view
tableView->setModel( &model );
}