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. QAbstractItemModel insert Row Error.

QAbstractItemModel insert Row Error.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 863 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.
  • P Offline
    P Offline
    Pada_
    wrote on last edited by
    #1

    Regenerated rowCount function in QAbstractItemModel. At first, Row Count is 0 in QMap.

    When you add QPushButton and click this button, InsertRow becomes one line.
    However, you can not select or modify these added lines.

    What should I do? Thank you.

    jsulmJ S 2 Replies Last reply
    0
    • P Pada_

      Regenerated rowCount function in QAbstractItemModel. At first, Row Count is 0 in QMap.

      When you add QPushButton and click this button, InsertRow becomes one line.
      However, you can not select or modify these added lines.

      What should I do? Thank you.

      jsulmJ Online
      jsulmJ Online
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Pada_ said in QAbstractItemModel insert Row Error.:

      What should I do?

      Explain better and show the relevant code.
      Where can't you select/modify the lines? How are you adding them?

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

      P 1 Reply Last reply
      1
      • jsulmJ jsulm

        @Pada_ said in QAbstractItemModel insert Row Error.:

        What should I do?

        Explain better and show the relevant code.
        Where can't you select/modify the lines? How are you adding them?

        P Offline
        P Offline
        Pada_
        wrote on last edited by
        #3

        @jsulm

        In rowCount (), only the number of returns is selected. If you press the button to insertRow, the line is added on the screen but you can not select or edit it.

        If the return value of rowCount is 2, you can select and modify up to 2 lines on the screen first, and nothing will work from the 3rd line added by pressing the button.

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

          Hi,

          How did you re-implement row count ?
          How are you implementing the rows related functions ?

          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
          1
          • P Pada_

            Regenerated rowCount function in QAbstractItemModel. At first, Row Count is 0 in QMap.

            When you add QPushButton and click this button, InsertRow becomes one line.
            However, you can not select or modify these added lines.

            What should I do? Thank you.

            S Offline
            S Offline
            Slawomir_Piernikowski
            wrote on last edited by
            #5

            @Pada_
            Have you checked if you have all Qt::Itemflags set:

            Qt::ItemFlags YourCustomizedModelName::flags(const QModelIndex &index) const
            {
               if (index.isValid())
               {
                   switch (index.column())
                   {
                   case 0:
                   {
                       return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled  | Qt::ItemIsSelectable | Qt::ItemIsEditable;
                   }
                   case 1:
                   {
                       return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled  | Qt::ItemIsSelectable | Qt::ItemIsEditable;
                   }
                   case 2: // end so on...
            
            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