PDA

View Full Version : Why this reference to tableView does not work ?



tonnot
21st September 2010, 19:29
I'm learning both c++ and QT ...


Myclase::Myclase(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Myclase)
{
ui->setupUi(this);
BuildTable();
}

Myclase::~Myclase()
{
delete ui;
}

void Myclase::BuildTable () {
QStandardItemModel model(4, 2);
ui->tableView.setModel(&model);
}

and I get the next error :

error: request for member 'setModel' in '((Myclase*)this)->Myclase::ui->Ui::Myclase::<anonymous>.Ui_Myclase::tableView', which is of non-class type 'QTableView*'

Of course I have a tableView in my ui.
Please help me ...

tbscope
21st September 2010, 19:35
Of course I have a tableView in my ui.

Yes, but it is a pointer.
Basic C++

ui->tableView->setModel(&model);

tonnot
21st September 2010, 19:51
Solved, I have another previous 'model'. All works if I change it to modelT.


Myclase::Myclase(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Myclase)
{
ui->setupUi(this);
BuildTable();
}

void Myclase::dir(){
QDirModel model;
}

Myclase::~Myclase()
{
delete ui;
}

void Myclase::BuildTable () {
QStandardItemModel modelT(4, 2);
ui->tableView.setModel(&modelT);
}

And now I have a new question.... The first 'model' are not private in 'Myclase::dir'

Excuse this basic ask.... and thank you for your time.

tbscope
21st September 2010, 20:01
I can only say: WTF!

tonnot
21st September 2010, 20:14
WTF : translated to spanish :
Pero qué cojones
Pero qué conchatumadres
Pero qué coño
Pero qué carajo
Pero qué chucha
Pero qué diablos
Pero qué joda
Pero qué mierda

well, I only ask for help. You simply could have answer ' Sorry but this is not the appropiate forum for this kind of questions' .

I put my question at 'newbie' chapter.
And, I simply want to learn.
Thank you any way

tbscope
21st September 2010, 20:16
Seriously, you ask for help with a pointer problem, you change something very different in your code that was not shown in your first post (and wasn't even your question), and now the error you posted is gone by changing the name of the model object?

No way!
That error did not reflect your changes, so hence the WTF!
But there might be the slight change I live in a weird universe.

Edit: And your second post didn't even contain a question.
Please learn at least how to ask a basic question.