Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSqlTableModel: How can I finish adding new row to the table with [Enter] key?
Forum Updated to NodeBB v4.3 + New Features

QSqlTableModel: How can I finish adding new row to the table with [Enter] key?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 880 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mstankie
    wrote on last edited by
    #1

    How can I finish adding new row to the table with [Enter] key? Do I have to catch the key event, or is there some settings I missed?
    In my app, the user can right-click the table and choose "add new row", then a new row is added with asterisk instead of number, and the left field is focused. User can then fill all cells, and hit enter in order to finish editing. But with Qt5.1 this is not enough -one has to focus other row in table...
    In doc: "OnFieldChange will behave like OnRowChange for newly inserted rows"
    I understand the idea that for newly inserted rows, behaviour is changed, but for the users it seems unexpected. Everyone thinks, the [Enter] key will finish editing and insert the row with new row number instead of asterisk. In Qt4.8 it worked normally, but after compiling my app in Qt5.1, it changed confusing me and the users.

    @void MyTab::New()
    {
    int row = model->rowCount();
    if(!model->insertRow(row))
    {
    if(model->lastError().isValid()) {
    QString errt = model->lastError().text();
    QMessageBox::critical(0, QObject::tr("DB Error"),errt);
    QLOG_ERROR()<<QString("MyTab::New() -err: %1.").arg(errt);
    }
    else {
    model->select();
    QLOG_WARN()<<QString(MyTab::New() -insertRow == FALSE, but no error."); //happens sometimes
    }
    };
    QModelIndex index = model->index(row, 0);
    view->setCurrentIndex(index);
    view->edit(index);
    }@

    MaciekS

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Since it looks like a behavior change (maybe a regression), I would recommend asking on the interest mailing list. You'll find Qt's developers/maintainers there (this forum is more user oriented)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved