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. Customize Qtableview , Qsqlquerymodel ..etc
Forum Updated to NodeBB v4.3 + New Features

Customize Qtableview , Qsqlquerymodel ..etc

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.5k 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.
  • A Offline
    A Offline
    advseo32
    wrote on last edited by
    #1

    i use Qsqlquerymodel with sqlite3 DBMS

    to retrieve data from database i use two Qtableview widgets

    i want the user to be able to work like so:

    the user uses only keyboard(no mouse )

    when the data grabed from database and showed in the Qtableview via Qsqlquerymodel the first row in the table must be selected by default

    the user uses arrow keys ( key_Down and Key_Up) to move between rows with "arrow.png" icon shown in verticalheader of Qtableview

    when the user clics Entrer_Key, the row selected will be appened in the second Qtableview

    plz help me , i have read model/view many times , and i figured out what really mean , but i still have a porbleme with customizing mytable view to work with

    Qkeymouse events, currentrowchanged signal

    1 Reply Last reply
    0
    • A Offline
      A Offline
      advseo32
      wrote on last edited by
      #2

      no body can help me ?

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

        Hi and welcome to devnet,

        Please allow at least 24 hours before bumping your own thread, not all people here live in the same timezone as you or maybe even can help you.

        Have a look at "activated":http://qt-project.org/doc/qt-4.8/qabstractitemview.html#activated and "QItemSelectionModel":http://qt-project.org/doc/qt-4.8/qitemselectionmodel.html

        You don't need to modify your QTableView if you are just going to react on the activated signal. You can do all the handling in the widget that will contain your two views.

        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
        • A Offline
          A Offline
          advseo32
          wrote on last edited by
          #4

          for the first probleme
          "when the data grabed from database and showed in the Qtableview via Qsqlquerymodel the first row in the
          table must be selected by default"

          i have used this code , and it works

          @ProduitView->setCurrentIndex(newIndex);@

          for the second problem

          "the user uses arrow keys ( key_Down and Key_Up) to move between rows "

          i have use this and is work perfectly

          @ProduitView->setSelectionBehavior(QAbstractItemView::SelectRows);
          ProduitView->setSelectionMode(QTableView::SingleSelection);@

          but i have still a probleme her

          with “arrow.png” icon shown in verticalheader of Qtableview"

          i start using roles like displayrole ... etc her what i think

          @ QVariant headerData(int section, Qt::Orientation orientation, int role) const
          {
          if(orientation == Qt::vertical)
          {
          if (the row is selected )
          {
          return icon(arrow.png)

          }
          }

          return QVariant();
          }@

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

            IIRC, using the DecorationRole should work, but why the icon ?

            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
            • A Offline
              A Offline
              advseo32
              wrote on last edited by
              #6

              [quote author="SGaist" date="1374351243"]IIRC, using the DecorationRole should work, but why the icon ?[/quote]

              how i can use decorationRole when the is selected ??

              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