Results 1 to 3 of 3

Thread: QTableView column header is invisible

  1. #1
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default QTableView column header is invisible

    Hi All,

    I have made a QTableView with 200 rows and 4 columns.. but the column header are invisible and here is my code snippet.

    toolform.cpp
    Qt Code:
    1. ToolForm::ToolForm(QDialog *parent, Qt::WindowFlags f)
    2. : QDialog( parent, f)
    3. {
    4. setupUi(this);
    5. setupModel();
    6. setupViews();
    7. init();
    8. }
    9.  
    10. ToolForm::~ToolForm()
    11. {
    12. }
    13.  
    14. void ToolForm::init()
    15. {
    16.  
    17. }
    18. void ToolForm::setupModel()
    19. {
    20. model = new QStandardItemModel(200, 4, this);
    21. model->setHeaderData(0, Qt::Horizontal, tr("NUMBER"));
    22. model->setHeaderData(1, Qt::Horizontal, tr("DIAMETER"));
    23. model->setHeaderData(2, Qt::Horizontal, tr("LENGTH"));
    24. model->setHeaderData(3, Qt::Horizontal, tr("UNITS"));
    25. }
    26.  
    27. void ToolForm::setupViews()
    28. {
    29. QTableView *tooltableView = new QTableView;
    30. tooltableView->setModel(model);
    31. QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
    32. tooltableView->setSelectionModel(selectionModel);
    33. }
    To copy to clipboard, switch view to plain text mode 

    toolform.h
    Qt Code:
    1. #ifndef TOOLFORM_H
    2. #define TOOLFORM_H
    3.  
    4. #include <QVariant>
    5. #include <QDialog>
    6.  
    7. #include "ui_toolform.h"
    8.  
    9.  
    10.  
    11. class ToolForm : public QDialog, private Ui::ToolForm
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. ToolForm( QDialog* parent = 0, Qt::WindowFlags f = Qt::FramelessWindowHint);
    17. ~ToolForm();
    18.  
    19. private:
    20.  
    21. void setupModel();
    22. void setupViews();
    23. void init();
    24.  
    25. QItemSelectionModel *selectionModel;
    26. };
    27.  
    28. #endif // TOOLFORM_H
    To copy to clipboard, switch view to plain text mode 

    How to resolve this issue.
    Thanks & Regards
    Sandeep G.R.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView column header is invisible

    try this:
    Qt Code:
    1. void ToolForm::setupViews()
    2. {
    3. QTableView *tooltableView = new QTableView;
    4. tooltableView->setModel(model);
    5. QItemSelectionModel *selectionModel = new QItemSelectionModel(model);
    6. tooltableView->setSelectionModel(selectionModel);
    7. toolrableView->show();
    8. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QTableView column header is invisible

    Hi Spirit,
    Thanks for the reply its working fine.
    Thanks & Regards
    Sandeep G.R.

Similar Threads

  1. QTableView header invisible
    By smacchia in forum Qt Programming
    Replies: 7
    Last Post: 20th November 2009, 03:21
  2. QTableView column trouble
    By nategoofs in forum Qt Programming
    Replies: 6
    Last Post: 27th October 2009, 20:14
  3. QTableView currentChanged <> selecting header
    By Everall in forum Qt Programming
    Replies: 4
    Last Post: 1st April 2009, 08:24
  4. QTableView without the first counter column?
    By pmaktieh.sirhc in forum Qt Programming
    Replies: 2
    Last Post: 4th January 2007, 22:03
  5. Replies: 0
    Last Post: 10th November 2006, 13: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.