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

Dropdown in Qtableview

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 4 Posters 6.1k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #9

    And that on one specific cell ?

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

    N 1 Reply Last reply
    0
    • SGaistS SGaist

      And that on one specific cell ?

      N Offline
      N Offline
      n-2204
      wrote on last edited by
      #10

      @SGaist yes

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

        Then why not just position a QComboBox there and hide it once it has been used ?

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

        N 1 Reply Last reply
        0
        • SGaistS SGaist

          Then why not just position a QComboBox there and hide it once it has been used ?

          N Offline
          N Offline
          n-2204
          wrote on last edited by
          #12

          @SGaist
          can you explain more?

          what I understood is, add a combobox and do the selection like if selected a then edit that to other value and if selected b then set the value to tableview cell and then hide combobox ??

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

            Yes, since you only have that one combo box for that unique action.

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

            N 1 Reply Last reply
            0
            • SGaistS SGaist

              Yes, since you only have that one combo box for that unique action.

              N Offline
              N Offline
              n-2204
              wrote on last edited by
              #14

              @SGaist

              hide the QCombobox how to do that?

              And one issue when editing the combobox , new value in adding to new index?
              how can I replace ?

              jsulmJ 1 Reply Last reply
              0
              • N n-2204

                @SGaist

                hide the QCombobox how to do that?

                And one issue when editing the combobox , new value in adding to new index?
                how can I replace ?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #15

                @n-2204 said in Dropdown in Qtableview:

                hide the QCombobox how to do that?

                https://doc.qt.io/qt-5/qwidget.html#hide

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                N 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @n-2204 said in Dropdown in Qtableview:

                  hide the QCombobox how to do that?

                  https://doc.qt.io/qt-5/qwidget.html#hide

                  N Offline
                  N Offline
                  n-2204
                  wrote on last edited by
                  #16

                  void QWidget::hide()
                  will hide the combobox from cell, and I have to show user the value of combobox selected by user like if combobox has 2 values when user selects a it is editable user can change it to t and if user selects b then its non editable and this value is set but if use hide then combobox will be hidden ?

                  jsulmJ 1 Reply Last reply
                  0
                  • N n-2204

                    void QWidget::hide()
                    will hide the combobox from cell, and I have to show user the value of combobox selected by user like if combobox has 2 values when user selects a it is editable user can change it to t and if user selects b then its non editable and this value is set but if use hide then combobox will be hidden ?

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #17

                    @n-2204 said in Dropdown in Qtableview:

                    if user selects b then its non editable and this value is set but if use hide then combobox will be hidden ?

                    Then show the selected value in a QLabel

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    N 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @n-2204 said in Dropdown in Qtableview:

                      if user selects b then its non editable and this value is set but if use hide then combobox will be hidden ?

                      Then show the selected value in a QLabel

                      N Offline
                      N Offline
                      n-2204
                      wrote on last edited by n-2204
                      #18

                      how to replace value in combobox?

                        testdropdown::testdropdown(QWidget *parent)
                      : QMainWindow(parent)
                       {
                      ui.setupUi(this);
                      
                      QStandardItemModel* stndrditem_model1 = NULL;
                      QComboBox* combobox1;
                      QStringList lst;
                      
                      if (stndrditem_model1 == NULL) {
                          stndrditem_model1 = new QStandardItemModel(10, 11, this);//row*col
                      }
                      
                      ui.tableView->setModel(stndrditem_model1);
                      ui.tableView->setColumnWidth(2, 1);
                      
                      const QModelIndex idx = stndrditem_model1 ->index(1, 1);
                      combobox1 = qobject_cast<QComboBox*>(ui.tableView->indexWidget(idx));
                       if (!combobox1) {
                           combobox1 = new QComboBox();
                           ui.tableView->setIndexWidget(idx, combobox1);
                       }
                      
                       lst<< "test" << "testdata";
                       combobox1->addItems(lst);
                       connect(combobox1, 
                      QOverload<int>::of(&QComboBox::currentIndexChanged), this, &testdropdown::testedit);
                      
                       }
                        void testdropdown::testedit(int indx) {
                      if (indx == 1) { //when user select testdata
                          combobox1->setEditable(true);
                      //when user enter at index 1 the new data added at index 2 I want to replace at same index  
                          //how to replace testdata string list value with new value in combobox and index should remain same which is entered by user  ??
                        
                      }
                      else{
                          combobox1->setEditable(false);
                      }
                      }
                      
                      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