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. (Solved) Focus in table widget
Forum Updated to NodeBB v4.3 + New Features

(Solved) Focus in table widget

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 3.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.
  • F Offline
    F Offline
    felipe.c.sousa
    wrote on last edited by
    #1

    Hi, someone know how put the focus in a item of a table widget?
    I search for something like "item(x,y)->setfocus();

    and one guy say that work:

    @ ui->twcadastro->setItemSelected(ui->twcadastro->item(1,0),true);@

    but do not work.

    sorry for my terrible english!
    i hope that you understand! hehehe

    From all, to all.

    1 Reply Last reply
    0
    • V Offline
      V Offline
      veeraps
      wrote on last edited by
      #2

      Try
      @
      ui->twcadastro->item(1,0)->setSelected(true);
      @

      1 Reply Last reply
      0
      • F Offline
        F Offline
        felipe.c.sousa
        wrote on last edited by
        #3

        i, try, but dont work.

        From all, to all.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rschaub
          wrote on last edited by
          #4

          make sure your item are "selectable and enabled":http://doc.qt.nokia.com/4.7-snapshot/qt.html#ItemFlag-enum
          item(1,0)->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);

          1 Reply Last reply
          0
          • F Offline
            F Offline
            felipe.c.sousa
            wrote on last edited by
            #5

            i resolve using that:

            @ui->twcadastro->openPersistentEditor(twcenter->item(1,0));
            ui->twcadastro->cellWidget(1,0)->setFocus();@

            From all, to all.

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rschaub
              wrote on last edited by
              #6

              if you want to open the editor when clicking on an item or when changing the focus, you have to set the editTriggers on the tableWidget accordingly:

              @
              widget->setEditTriggers(QAbstractItemView::CurrentChanged);
              @

              s.a. "EditTrigger-enum":http://doc.qt.nokia.com/4.7-snapshot/qabstractitemview.html#EditTrigger-enum

              1 Reply Last reply
              0
              • F Offline
                F Offline
                felipe.c.sousa
                wrote on last edited by
                #7

                i want open for write . but thanks.

                From all, to all.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  "QAbstractItemView::edit() ":/doc/qt-4.8/qabstractitemview.html#edit should do what you want.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    felipe.c.sousa
                    wrote on last edited by
                    #9

                    thanks! =D

                    From all, to all.

                    1 Reply Last reply
                    0
                    • G Offline
                      G Offline
                      gdouglas7
                      wrote on last edited by
                      #10

                      was util for me

                      Qt Developer
                      Student of Information System

                      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