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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:08:13+00:00 2026-05-27T05:08:13+00:00

Having an issue with displaying a loaded image in a QGraphicsScene. CTextBox::CTextBox(QWidget* parent /*

  • 0

Having an issue with displaying a loaded image in a QGraphicsScene.

CTextBox::CTextBox(QWidget* parent /* = NULL */)
{   
QPixmap image;

image.load("basketball.png");

grid = new QGridLayout();
grid->setSpacing(1);    
textBrowser = new QTextEdit(this);
treeView = new QTreeView;

treeLabel = new QLabel;
treeLabel->setText("Tree View:");

debugLabel = new  QLabel;
debugLabel->setText("Debug:");  

standardModel = new QStandardItemModel;
rootNode = standardModel->invisibleRootItem();
treeView->setModel(standardModel);



QGraphicsPixmapItem pixmapitem(image);




//scene.addText("Graphics");
scene.addItem(&pixmapitem);

//rect = scene.addRect(QRectF(0,0, 100, 100));

//QGraphicsItem *item = scene.itemAt(50, 50);
widget = new QWidget();
view = new QGraphicsView;
view->setScene(&scene);
view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));




//proxy = scene.addWidget(widget);
//label = new QLabel();

grid->addWidget(textBrowser, 1, 0);
grid->addWidget(debugLabel, 0, 0);
grid->addWidget(treeView, 1, 1);
grid->addWidget(treeLabel, 0, 1);
//grid->addWidget(&image, 2,0);
//grid->addWidget(view, 2, 0);
//grid->addWidget(widget, 2, 0);
//grid->addWidget(proxy, 2,0);

view->show();

//widget->setLayout(view);

//widget->show();
setLayout(grid);


//label->addItem()
}

Basically when I try and load the image in a QGraphicsScene it seems to scale up to the size of the image but displays a white screen. I can add text to the graphics scene fine and that will display correctly. Now if I try to do add the image into a label on a different widget it displays fine. Any ideas why?

Cheers.

  • 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-27T05:08:14+00:00Added an answer on May 27, 2026 at 5:08 am

    You don’t see it because you pass a reference to a local object of the constructor. The pixmap item will be destructed immediately after your constructor ends. Use dynamic allocation instead.

    QGraphicsPixmapItem* pixmapitem = new QGraphicsPixmapItem(image);
    scene.addItem(pixmapitem);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issue with png image on IE6 and tried to search every
I am quite new to rails... I am having an issue with displaying of
I'm having an issue with the PDF displaying outside the viewable area of the
I'm having an issue displaying an object in a checked list box in C#.
Having issue with displaying the Data from a second Activity. when I run the
I'm having some troubles with displaying a graph. It's a very strange issue, because
I'm having an issue where our cell table is only displaying 15 rows. I
I'm having trouble displaying an image in a UIWebView. I retrieve html content from
currently im working on symfony based large application. i m having issue on displaying
I am having an issue selecting and displaying a substring from each of the

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.