Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7624207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:54:10+00:00 2026-05-31T04:54:10+00:00

I have a window which contains a QTreeView ( databaseTreeView ) on a subclass

  • 0

I have a window which contains a QTreeView (databaseTreeView) on a subclass of QAbstractTableModel (via a QSortFilterProxyModel).
I have an [Add] button which calls ui->databaseTreeView->model()->insertRow(ui->databaseTreeView->model()->rowCount());.
I also have an [Edit] Button, which uses ui->databaseTreeView->selectionModel()->currentIndex(); to pass an index to an editor window.

I’d like to have the [Add] button automatically open an editor with the index of the newly created item, but as the model is sorted, I can’t use the row number where I inserted the row. Plus insertRows() only returns a bool (an index would be far more handy for my situation, so I’m wondering if anyone can tell me how to get the index of the newly added item).

I’m willing to devote two or three hours to it, refactoring if there’s no alternative, but I would have thought it should be fairly simple. I’m looking inquisitively at the QAbstractItemModel::rowsInserted signal, but that just returns the rows I gave insertRows(), and edits the last item in the list, regardless of whether it was the item just added.

The full source can be found at https://github.com/megamasha/FlashKard for anyone to take a closer look.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:54:11+00:00Added an answer on May 31, 2026 at 4:54 am

    Well, it seems I managed to answer my own question – I added my own signal to the model class, and sent it from the addRows() function. I then connected it to a slot in the appropriate window, so it could create an editor as its child.

    I’d still be interested to hear suggestions that feel less like a kludgey workaround – I feel like I should be able to use preexisting slots to achieve the same goal.

    I shall see if mapToSource() can be of use…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF window, which contains a button called Cancel. Under ordinary circumstances
I have a Swing window which contains a button a text box and a
I have a window in WPF which shows some media contents. This content contains
I have a UserControl which contains a TextBox . When my main window loads
I have a jQuery Model windows which contains a form. On creating of the
I have a page which contains a div which must be resized via JS
Im using cocoa in xcode 4.4 and I have a window which contains a
I have a scrolled window, which contains a drawing area in pygtk. I would
In my main window, I have a child control(user control) which contains a text
I have created a Popup window which contains month view to pick up date.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.