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
Qt 6.11 is out! See what's new in the release blog

(Solved) Focus in table widget

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 4.0k 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.
  • ? Offline
    ? Offline
    A Former User
    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

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        i, try, but dont work.

        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
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            i resolve using that:

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

            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
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                i want open for write . but thanks.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    thanks! =D

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #10

                      was util for me

                      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