Getting TableView to strech with Dialog
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
Code:
#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
){
// 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
model.setItem(0,0,item);
model.setItem(0,1,item);
model.setItem(0,2,item);
model.setItem(0,3,item);
// assign model to view
tableView->setModel( &model );
}
Re: Getting TableView to strech with Dialog
Re: Getting TableView to strech with Dialog
Actually I have defined a layout. As I said, with the designer I placed a vertical layout object on the dialog and then inserted the table view into the layout. Is there a command where I assign the layout to the dialog??
Re: Getting TableView to strech with Dialog
Right mouse button click on the dialog.
From the context menu choose grid layout.
Good luck!
Re: Getting TableView to strech with Dialog
Grid layout has no differnet affect than vertical layout.