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 8285537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:29:36+00:00 2026-06-08T11:29:36+00:00

Hello I tried to implement a custom QAbstractModel to use it on QtreeView. Main

  • 0

Hello I tried to implement a custom QAbstractModel to use it on QtreeView.

Main requirement was to store as a tree QDomNodes so i can easily access/delete/add childrens.

But in this method i receive a segmentation fault

ProjectTreeItem *ProjectTreeModel::getItem(const QModelIndex &index) const
{
    if (index.isValid()) {
         ProjectTreeItem *item = static_cast<ProjectTreeItem*>(index.internalPointer());
         if (item) return item;
     }
     return rootItem;
}

here is entire file:

http://pastebin.com/HmWZwVmC – projecttreemodel.cpp

http://pastebin.com/4nDXDVX0 – projecttreeitem.cpp

here what i try to do:

void Ide::slotDeleteItem()
{
    /**
      * ui->projectsView is a QTreeView with setModel(model)
          * model is a ProjectTreeModel
          */
    QItemSelectionModel* sel = ui->projectsView->selectionModel();

    QModelIndexList lst = sel->selectedIndexes();

    QModelIndex ind = lst.at(0);

    ProjectTreeItem* item = model->getItem(ind);

/** SEGFAULT even if getItem is moved to public(default is private) **/
    qDebug() << item->data(Qt::DisplayRole).toString();
/** SEGFAULT **/
    qDebug() << model->data(ind,Qt::DisplayRole);

/** Works and display information correct, but i need to access to ProjectTreeItem **/

    qdebug() << ind.data(Qt::DisplayRole);
}

i’m not sure about what “internal pointer” stuff is doing, if anyone can help, please ?

thanks!

  • 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-06-08T11:29:37+00:00Added an answer on June 8, 2026 at 11:29 am

    I found the source of the problem, it wasnțt de model problem, I used a QProxyModel to filter some nodes and all QModelIndex provided were invalid. Do not use QproxyModel if you want to use selectionModel to get selected indexes.

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

Sidebar

Related Questions

I tried the following code tree. If I put the header file hello.h into
As The Title said, I tried to implement a custom taxonomy in wordpress, i
Hello I tried to implement unit testing for a protected slot In the testing
Hello friends I have tried many times but I am not successful than please
I tried running a python script: print Hello, World! And I get this error:
Hello I am developing a map view I tried to following way I created
I tried with no success: webBrowser1.Document.ExecCommand(alert('Hello World!'), true, null); also tried: private void webBrowser1_DocumentCompleted(object
I have tried to generate Hello World with openxml sdk. To my surprise when
hello i am having same issue, i tried your solution but it didnt help
When I tried to do a simple modification of the hello android program that

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.