Results 1 to 7 of 7

Thread: how coult this happen with the QTableView Column insert?

  1. #1
    Join Date
    May 2010
    Location
    China
    Posts
    66
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default how coult this happen with the QTableView Column insert?

    i have a slot function on insert a column with the qtableview,and the colde are bleow,i use the libqxt csvmodel function;:
    Qt Code:
    1. void PFDataGrid::insertColumn(int columnNumber)
    2. {
    3. QxtCsvModel *csvModel=(QxtCsvModel*)(this->model());
    4.  
    5. csvModel->insertColumn(columnNumber);
    6.  
    7.  
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    but when i insert a column ,there is always will insert a column at the end ,can't be edit ,and the first column did't have column number ,can anyone help my ,i will be appreciate it未命名.JPG
    Last edited by wysota; 13th December 2010 at 08:39. Reason: changed [qtclass] to [code]

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how coult this happen with the QTableView Column insert?

    What value does columnNumber have? Does insertColumn() return true or false?

  3. #3
    Join Date
    May 2010
    Location
    China
    Posts
    66
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how coult this happen with the QTableView Column insert?

    Qt Code:
    1. void PFDataGrid::insertColumn(int columnNumber)
    2. {
    3. QxtCsvModel *csvModel=(QxtCsvModel*)(this->model());
    4.  
    5. bool success=csvModel->insertColumn(columnNumber);
    6.  
    7.  
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    it returns true;and i use qDebug()<<"column count:"<<columnCount();the columns' count did add
    Last edited by wysota; 13th December 2010 at 08:39. Reason: changed [qtclass] to [code]

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how coult this happen with the QTableView Column insert?

    What value does columnNumber not columnCount() have? Clearly the columnCount is increasing but you are claiming the new column is not where you think it should be.

    Please put [code] tags around your code. It is one of the # tools on the tool bar.

  5. #5
    Join Date
    May 2010
    Location
    China
    Posts
    66
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how coult this happen with the QTableView Column insert?

    after i call the insertColumn(int columnNumber) function ,it will add a column at the end of the tableview ,and it can't be edit ,but also it will insert a column before the place i inserted,and the column did't have a column header,the header is blank

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how coult this happen with the QTableView Column insert?

    This is a libqxt bug that you should report. The following code shows the problem:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3. #include <QxtCsvModel>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. QxtCsvModel m("test.csv");
    10. v.setModel(&m);
    11. v.show();
    12. qDebug() << "Before:" << m.columnCount();
    13. m.insertColumn(2);
    14. qDebug() << "After: " << m.columnCount();
    15.  
    16. return app.exec();
    17. }
    18. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. TEMPLATE = app
    2. TARGET =
    3. DEPENDPATH += .
    4. INCLUDEPATH += .
    5. QT += sql
    6. CONFIG += qxt
    7. QXT += core
    8.  
    9. # Input
    10. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

    test.csv:
    Qt Code:
    1. 0,1,2,3,4,5
    2. 0,1,2,3,4,5
    3. 0,1,2,3,4,5
    4. 0,1,2,3,4,5
    To copy to clipboard, switch view to plain text mode 

    Output:
    Qt Code:
    1. Before: 6
    2. After: 7
    To copy to clipboard, switch view to plain text mode 
    but 8 columns are visible in the QTableView after the insertColumns() call.

  7. #7
    Join Date
    May 2010
    Location
    China
    Posts
    66
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how coult this happen with the QTableView Column insert?

    ok ,i will report this bug to the LibQxt team

Similar Threads

  1. Qtableview, insert and selection
    By noValue in forum Qt Programming
    Replies: 7
    Last Post: 4th May 2010, 00:06
  2. Insert into array column
    By wirasto in forum Newbie
    Replies: 3
    Last Post: 9th November 2009, 15:07
  3. Insert data to QTableView
    By Lodhart in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2009, 09:38
  4. Select row in QTableView after insert.
    By fede in forum Newbie
    Replies: 1
    Last Post: 14th April 2009, 15:18
  5. Insert QCheckBox into QTableView
    By wind in forum Qt Programming
    Replies: 3
    Last Post: 8th October 2006, 16:15

Tags for this Thread

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.