Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]QGraphicsView - no QPixmap shown load from resources (Linux)
Forum Updated to NodeBB v4.3 + New Features

[Solved]QGraphicsView - no QPixmap shown load from resources (Linux)

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 9.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ruehlchr
    wrote on last edited by
    #1

    Hi All,

    may I stay on the tube - but I cannot display a QPixmap within a Dialog Window ..
    and stuck's for a couple of days. I use the QtDesigner to create the Dialog.
    No Errors show in the qDebug output.
    Just have a review below. May someone can open my eyes.

    @
    AboutDialog::AboutDialog(QWidget *parent)
    : QDialog(parent)
    {
    QGraphicsScene scene;
    QString resourcePath = ":/images/about.png";

    setupUi(this);

    if( ! QFile::exists(resourcePath) )
    {
    qDebug("*** Error - Resource path not found : "%s"", resourcePath.toLatin1().data());
    }
    else {

    QPixmap p1(resourcePath);
    
    if ( p1.isNull() ) {
      qDebug("*** Error - Null QPixmap");
    }
    else {
      QGraphicsPixmapItem *item_p1 = scene.addPixmap(p1);
      item_p1->setVisible(true);
      //QGraphicsTextItem *item_txt = scene.addText("APTool v1.0");
      //item_txt->setVisible(true);
      gvViewPort->setScene(&scene);
      gvViewPort->show();
    }
    

    }
    }
    @

    @

    QGraphicsView *gvViewPort;

    void setupUi(QDialog *About)
    {
        if (About->objectName().isEmpty())
            About->setObjectName(QString::fromUtf8("About"));
        About->resize(400, 300);
        QIcon icon;
        icon.addFile(QString::fromUtf8(":/images/gts.png"), QSize(), QIcon::Normal, QIcon::Off);
        About->setWindowIcon(icon);
        About->setModal(true);
        gvViewPort = new QGraphicsView(About);
        gvViewPort->setObjectName(QString::fromUtf8("gvViewPort"));
        gvViewPort->setGeometry(QRect(40, 10, 312, 239));
    

    ...
    @

    and all I see is a white frame.

    !http://www.gtsys.com.hk:8080/~chris/Screenshot-About.png(About-dialog-no-pixmap)!

    thanks.
    Chris

    If you want to make it fly. QTit!

    1 Reply Last reply
    0
    • R Offline
      R Offline
      ruehlchr
      wrote on last edited by
      #2

      Solved:

      The QGraphicsScene scene should be a private member of the class.

      private:
      QGraphicsScene *scene;

      and in the constructor
      scene = new QGraphicsScene();

      Cheers

      If you want to make it fly. QTit!

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #3

        [quote author="ruehlchr" date="1306816114"]Solved:

        The QGraphicsScene scene should be a private member of the class.

        private:
        QGraphicsScene *scene;

        and in the constructor
        scene = new QGraphicsScene();

        Cheers
        [/quote]

        You probably can do in the constructor:
        @
        QGraphicsScene *scene = new QGraphicsScene();

        @

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved