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

  • SEARCH
  • Home
  • 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 6124399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:07:42+00:00 2026-05-23T16:07:42+00:00

I’m trying to implement QAbstractItemModel for QTreeView. I have problem with inserting rows. I

  • 0

I’m trying to implement QAbstractItemModel for QTreeView. I have problem with inserting rows.
I noticed that if I insert at the beginning of my application all works fine. But If I insert rows later – after some other operations (like selections etc.) new items stay invisible. Moreover QTreeView seems to doesn’t work at all! Do I have to emit some signals to notify QTreeView about rows insertion?

This is my insertion method:

bool LayersModel::insertRows(int position, int count, const QModelIndex  & parent)
{
    LayersModelItem * parentItem = getItem(parent);
    if (position > parentItem->childCount())
        return false;
    beginInsertRows(parent,position,position+count-1);
    bool result = true;
    for (;count;--count)
        result &= parentItem->insertChildren(position, new LayersModelItem());
    endInsertRows();
    return result;
}

LayersModelItem is class with QList with its children and data.

Full code of my project (KDE libs needed) is here:
https://github.com/coder89/PhotoFramesEditor/tree/v0.0.8
To see the problem select one of blue item on main window and then right-click on it and select “Delete item”. (this method is in Canvas::removeItems()) and it is completly commented – I’m desperate and I’ve tried to find reason of this problem… (in fact it wasn’t delete anything – it adds new item).

Thanks for any help & advice!

  • 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-23T16:07:43+00:00Added an answer on May 23, 2026 at 4:07 pm

    Just a quick guess, the QT Doc for QAbstractItemModel says…

    The model emits signals to indicate
    changes. For example, dataChanged() is
    emitted whenever items of data made
    available by the model are changed.
    Changes to the headers supplied by the
    model cause headerDataChanged() to be
    emitted. If the structure of the
    underlying data changes, the model can
    emit *layoutChanged()
    to indicate to
    any attached views that they should
    redisplay any items shown, taking the
    new structure into account*.

    So i guess, you need to emit layoutChanged() signal from your model (whenever you change the data in model) in order to update connected views.

    Also read the QT docs for model view architecture, how it is implemented in QT

    see if that helps, if it doesn’t i will try to download your code and debug it and see, what’s wrong.
    Good Luck

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

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.