I am not used to using Qt, and trying to do something simple but it wont work --
ID: 3818113 • Letter: I
Question
I am not used to using Qt, and trying to do something simple but it wont work
-- I have made a model based table:
in the black square, i have tried to title it without luck
furtherdown i have some random data, which i would like to list in the table, how do i go about doing this?
the class i am working on like everybody can see is called startpage
Thankyou very much
6 StartPage StartPage (QWidget parent QWidget (parent), 8 v ui (new Ui: StartPage) QStringList titles WindowTitle ("Profiles set ui profil es setColumnWidth (5,3); Table titles Profile Name "Temperature Roasting fi me" ui profil es setHor Labels (titles) Table 17 18 v StartPage Start Page 19 delete ui; 20 21 22 23 Y void StartPage start Bu clicked() tto 24 emit change Page (Pages ROAST PAGE) 25 26 27 28 v void StartPage n profil es Bu tto clicked() 29 float temp 213.5 int time 25 31 QString name john 32 33 35Explanation / Answer
I tried this code and it worked for me .
StartPage::StartPage(QWidget *parent) :
QStartPage(parent),
ui(new Ui :: StartPage)
{
ui->setupUi(this);
QStandardItemModel * model = new QStandardItemModel ( 5,3,this); //5 rows and 3 columns
//code for creating table headers
model ->setHorizontalHeaderItem(0, new QStandardItem(QString(“Profile Name”)));
model ->setHorizontalHeaderItem(1, new QStandardItem(QString(“Temperature”)));
model ->setHorizontalHeaderItem(3, new QStandardItem(QString(“Roasting Time”)));
QStandardItem *firstRow = new QStandardItem(QString("ColumnValue"));//listing data randomly
model->setItem(0,0,firstRow);// here code for listing data
ui->tableView->setModel(model);
}
StartPage :: StartPage ()
{
delete ui;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.