Results 1 to 6 of 6

Thread: Why this reference to tableView does not work ?

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Why this reference to tableView does not work ?

    I'm learning both c++ and QT ...

    Qt Code:
    1. Myclase::Myclase(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::Myclase)
    4. {
    5. ui->setupUi(this);
    6. BuildTable();
    7. }
    8.  
    9. Myclase::~Myclase()
    10. {
    11. delete ui;
    12. }
    13.  
    14. void Myclase::BuildTable () {
    15. QStandardItemModel model(4, 2);
    16. ui->tableView.setModel(&model);
    17. }
    To copy to clipboard, switch view to plain text mode 

    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 ...

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Why this reference to tableView does not work ?

    Quote Originally Posted by tonnot View Post
    Of course I have a tableView in my ui.
    Yes, but it is a pointer.
    Basic C++
    Qt Code:
    1. ui->tableView->setModel(&model);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why this reference to tableView does not work ?

    Solved, I have another previous 'model'. All works if I change it to modelT.

    Qt Code:
    1. Myclase::Myclase(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::Myclase)
    4. {
    5. ui->setupUi(this);
    6. BuildTable();
    7. }
    8.  
    9. void Myclase::dir(){
    10. QDirModel model;
    11. }
    12.  
    13. Myclase::~Myclase()
    14. {
    15. delete ui;
    16. }
    17.  
    18. void Myclase::BuildTable () {
    19. QStandardItemModel modelT(4, 2);
    20. ui->tableView.setModel(&modelT);
    21. }
    To copy to clipboard, switch view to plain text mode 

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Why this reference to tableView does not work ?

    I can only say: WTF!

  5. #5
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why this reference to tableView does not work ?

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Why this reference to tableView does not work ?

    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.

Similar Threads

  1. Replies: 2
    Last Post: 4th September 2010, 06:18
  2. Replies: 2
    Last Post: 13th December 2009, 20:27
  3. tableview
    By GuL in forum Newbie
    Replies: 1
    Last Post: 26th August 2008, 17:18
  4. checkboxes in a tableview,
    By mimmo_kallon in forum Newbie
    Replies: 3
    Last Post: 13th March 2008, 19:01
  5. help in tableview
    By bala in forum Qt Programming
    Replies: 3
    Last Post: 12th November 2007, 15:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.