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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:36:07+00:00 2026-06-11T12:36:07+00:00

I am using Qt to draw out some data visualisations. I have lines which

  • 0

I am using Qt to draw out some data visualisations. I have lines which indicate certain important points along a timeline, but I would like to be able to remove these lines from view so that the information underneath is more clearly visible.

I understand how to remove them from sight, but the problem is how to find which QGraphicsItems in the scene’s view are Lines and which are not.

I have tried using

try {
    qgraphicsitem_cast<QGraphicsLineItem>(scene->items()[i]);
} catch (...) {
}

But this doesn’t even compile. I tried checking the output of qgraphicsitem_cast() to see if was 0, but the compiler didn’t like that, either.

This is my most current code:

void Plotter::showHideLines() {
    int i;
    QGraphicsLineItem l;

    for (i = 0; i < scene->items().count(); i++) {
        try {
            qgraphicsitem_cast<QGraphicsLineItem>(scene->items()[i]);
            scene->items()[i]->setVisible(!scene->items()[i]->isVisible());
        } catch (...) {
        }
    }
}

Ignore l, I didn’t bother to delete it after trying something else.

I am pretty new to Qt, I have just been learning it over the last few days. Can anybody help?

  • 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-11T12:36:08+00:00Added an answer on June 11, 2026 at 12:36 pm

    I wouldn’t advise iterating through every scene item, just to hide a certain type as things will get slow when the number of items gets large.

    Instead, whenever a line is created, add it to a list. When they need to be hidden, iterate through list and hide them. It takes slightly more memory, but is much faster, safer, and requires less coding.

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

Sidebar

Related Questions

I have a time series data which I can draw using jfreechart. the issue
I have some data in mysql that I load up in php and draw
I have a table that i want to filter out duplicated data when using
I'm using CALayers to draw to a UITableViewCell. I'm trying to figure out how
I have an area where the user can draw using a finger. This area
I'm using Silverlight to draw some shapes and text on top of an image.
I am using Raphael to draw some paths. Each path has an associated rectangle
Is there some sample code or a tutorial out there about how to draw
I'm going out of my mind a bit here. I'm trying to draw some
I have been using gnuplot for some time now and set terminal pdfcairo set

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.