Results 1 to 3 of 3

Thread: How automatically Select first row after QTableView is created

  1. #1
    Join Date
    May 2014
    Posts
    5
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default How automatically Select first row after QTableView is created

    I have a single QTableView(model based).I need to give focus on first row of QTableview while data displaying.While selecting first row, data will displays in line edit boxes.
    I am not able to foucus on the first row selection. QSqlQueryModel i am using
    If I manually clicked then its working,means first row data displaying in Line edit boxes.please suggest.

    my code below

    ui->TbleViewUserMgmt->setSelectionMode(QAbstractItemView::SingleSelec ti on);
    ui->TbleViewUserMgmt->selectRow(0);
    ui->TbleViewUserMgmt->setFocus();

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How automatically Select first row after QTableView is created

    Does it not select the first row?

    Or do you want to put the row into edit mode?
    See QAbstractItemView::edit() for that

    Cheers,
    _

  3. #3
    Join Date
    May 2014
    Posts
    5
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Windows

    Default Re: How automatically Select first row after QTableView is created

    Using the below code my Table issue resolved

    QModelIndexList indexes = ui->TbleViewUserMgmt->selectionModel()->selection().indexes();
    QModelIndex index = indexes.at(0);
    on_TbleViewUserMgmt_activated(index);

Similar Threads

  1. Replies: 2
    Last Post: 16th May 2014, 15:36
  2. QTableView select a whole row?
    By qlands in forum Qt Programming
    Replies: 1
    Last Post: 22nd August 2011, 11:22
  3. Replies: 6
    Last Post: 10th June 2011, 20:44
  4. How select next row in QTableView
    By estanisgeyer in forum Qt Programming
    Replies: 8
    Last Post: 17th June 2009, 20:02
  5. disable automatically created accelerator keys
    By joschi58 in forum Qt Programming
    Replies: 2
    Last Post: 17th January 2008, 10:50

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.