Results 1 to 6 of 6

Thread: Use Designer to create Table View, How to handle the edit event on Table View?

  1. #1
    Join Date
    Mar 2010
    Posts
    68
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Use Designer to create Table View, How to handle the edit event on Table View?

    Somebody help me a way...

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Use Designer to create Table View, How to handle the edit event on Table View?

    Quote Originally Posted by Kevin Hoang View Post
    Somebody help me a way...
    First, explain your problem to 'somebody'. Until now we can't help you much. What do you understand by 'edit event'? Do you know what is a Model/View architecture and how it works in Qt?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Use Designer to create Table View, How to handle the edit event on Table View?

    You don't create table views with the designer.
    Do it like this:

    Qt Code:
    1. model = new QSqlTableModel(this, <QSqlDatabase>);
    2. view = new QTableView();
    3. view->setModel(model);
    4. model->setTable(<table name>);
    5. header = new QHeaderView(Qt::Horizontal, this);
    To copy to clipboard, switch view to plain text mode 

    Don't forget the declarations for the model, view and header in the .h file.

    Set your header column names with model->setHeaderData(<col>, Qt::Horizontal, "col name");
    You can edit the data by clicking in the table cells.
    Check out the doc here: http://doc.trolltech.com/4.5/model-v...ogramming.html

  4. #4
    Join Date
    Mar 2010
    Posts
    68
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Use Designer to create Table View, How to handle the edit event on Table View?

    Thanks!

    I mean that, I want to control it, such as: when users try to edit a cell, the default of this cell is a short name off previous cell, how to do like that?

  5. #5
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Use Designer to create Table View, How to handle the edit event on Table View?

    I'm not quite sure I understand what you are trying to do. But if you are trying to modify the contents of a table cell when a user clicks on it, you first need to determine which cell by using QModelIndexList QItemSelectionModel::selectedIndexes () to get the index of the selected cell.

  6. #6
    Join Date
    Mar 2010
    Posts
    68
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Use Designer to create Table View, How to handle the edit event on Table View?

    @waynew: I know that features, but I want to process over default functions.
    An example: I want to make a auto complete function for editing

Similar Threads

  1. Replies: 1
    Last Post: 3rd April 2010, 15:47
  2. Set height for table view
    By sasi in forum Qt Programming
    Replies: 1
    Last Post: 29th July 2009, 08:07
  3. Table view
    By tulsi in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2009, 08:07
  4. Table Widget Vs. Table View
    By winston2020 in forum Qt Programming
    Replies: 2
    Last Post: 19th October 2008, 09:56
  5. View/edit database in a table and in a form
    By igorko in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2006, 09:09

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.