Results 1 to 4 of 4

Thread: Displaying an image with Qt

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    Displaying an image with Qt

    i am doing a project in QT, Can any one tell me how to make a images (.jpeg) using QT.... ,I cant find how to place a QLabel in the mainwindow thought Graphics View.

    Thank you in advance

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    Re: Displaying an image with Qt

    Code:
    QLabel * label_img = new QLabel (this);
     QPixmap * pic_img = new QPixmap ( "d1/d2/img.jpg");
    	  label_img -> setPixmap (pixmap_img *);
    
     QGridLayout gridLayout * = new QGridLayout;
     gridLayout -> addWidget (label_img);
     setLayout (gridLayout);

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Displaying an image with Qt

    Code:
    #include ...
    
    int main(int arg, char *arg[])
    {
        QApplication a(arg, arg);
        QGraphicsScene scene;
        QGraphicsView view(&scene);
        QGraphicsPixmapItem item(QPixmap("d:\\image.png"));
        scene.addItem(&item);
        view.show();
        return b.exec();
    }

  4. #4
    Join Date
    Dec 2008
    Posts
    177

    Re: Displaying an image with Qt

    Code:
    QWidget * widget = new QWidget;
     QLabel * label = new QLabel;
     QPixmap * pic_img = new QPixmap ( "1.jpg");
     / / 1 is in the directory that contains exe
    
     label -> setPixmap (pic_img *);
    
     QGridLayout gridLayout * = new QGridLayout (widget);
     gridLayout -> addWidget (label, 0, 0);
     setLayout (gridLayout);    
    
     widget -> show ();

Similar Threads

  1. Replies: 7
    Last Post: 15-02-2012, 05:29 AM
  2. problem with displaying image
    By ibiangalex in forum Software Development
    Replies: 1
    Last Post: 27-10-2010, 03:31 AM
  3. Nokia 6303, problem displaying image(s)
    By Ganaka in forum Portable Devices
    Replies: 4
    Last Post: 19-04-2010, 10:28 AM
  4. Displaying an image and text in a JSP
    By samualres in forum Software Development
    Replies: 7
    Last Post: 20-03-2010, 10:43 AM
  5. Displaying an Image In a JSP With a Access database
    By Henryosa in forum Software Development
    Replies: 5
    Last Post: 12-03-2010, 03:52 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,985,552.90881 seconds with 17 queries