Results 1 to 3 of 3

Thread: delete record from qsqltable

  1. #1
    Join Date
    May 2011
    Posts
    39
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default delete record from qsqltable

    please help
    how to delete record from qsqltablemodel....
    I have ideas about inserting data but I don't have idea about how to delete record from qsqltablemodel

  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: delete record from qsqltable

    Have you even briefly read the QSqlTableModel docs? Does QSqlTableModel::removeRows() sound promising?

    Your underlying SQL table will almost certainly need a defined primary key.

  3. #3
    Join Date
    Jun 2011
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: delete record from qsqltable

    Hi! I'm new here and new to Qt in general.
    I'm trying to do the same thing. Since QSqlTableModel::removeRow() needs row index as argument, how can I get the index of selected row? I looked here: http://www.qtforum.org/article/14578...ablemodel.html but this doesn't seem to work. I get those errors while I try to compile:

    Qt Code:
    1. soltys@ubuntu:~/qt/neurohelper_v0.2$ make
    2. g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_SQL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtSql -I/usr/include/qt4 -I. -o tableeditor.o tableeditor.cpp
    3. tableeditor.cpp: In member function ‘void TableEditor::delRow()’:
    4. tableeditor.cpp:80: error: ‘class QSqlTableModel’ has no member named ‘selectionModel’
    5. tableeditor.cpp:81: error: ‘class QItemSelectionModel’ has no member named ‘selectionIndex’
    6. tableeditor.cpp:85: error: no matching function for call to ‘QSqlTableModel::removeRow(const QModelIndex&)’
    7. /usr/include/qt4/QtCore/qabstractitemmodel.h:314: note: candidates are: bool QAbstractItemModel::removeRow(int, const QModelIndex&)
    8. make: *** [tableeditor.o] Error 1
    To copy to clipboard, switch view to plain text mode 
    BlogBits | YouTube | Flickr | MAL | Last.fm | Web Profile
    CLI is not an UI, it's a way of life!

Similar Threads

  1. Replies: 7
    Last Post: 27th November 2010, 15:55
  2. QTableWidget to QSqltable
    By manmohan in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2010, 12:08
  3. Replies: 3
    Last Post: 6th May 2010, 04:02
  4. Replies: 3
    Last Post: 26th March 2010, 04:32
  5. Replies: 4
    Last Post: 19th February 2009, 11:10

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
  •  
Qt is a trademark of The Qt Company.