Qt: QTableView Tutorial I

I am interesting with QTableView. I try to search QTableView tutorial, but difficult to get this tutorial. So, I try to create basic QTableView Tutorial. This is output from my first QTableView Tutorial:

First, copy this text and save as main.cpp.

Second, create tableview class to show QTableView in our program. Copy this text and save as tableview.cpp

Third, create tableview header. Copy this text and save as tableview.h

Create pro file, copy this text as tblview1.pro

Compile program with command qmake and make. You can download  this QTableview tutorial source code at here.

8 thoughts on “Qt: QTableView Tutorial I

  1. thanks toto for the post, but i have a problem.

    i am not able to include the header files which u have included in tableview.h file.
    its showing error that it cant find the header files.

    • What system operation and editor you use? This error because you dont set Qt path (QTDIR, QTLIB, QTINC) correctly. You can set this location in your vaforite editor (eclipse or QtCreator) or if you use console to compile your program. Please check in you editor setting path.
      you can set this path in Environtment Variable (in windows. right click mycomputer->advanced->Environtment variables->system variables->new). Or if you use linux, you can add this setting in /etc/profile.d/. add new file (example qt4.sh) and add Qt Path.
      Example : this is my Qt path in linux :
      export PATH=$PATH:$QTDIR/bin

      save this file as qt4.sh in /etc/profile.d

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.