Results 1 to 2 of 2

Thread: Image don't appear in the window.

  1. #1
    Join Date
    Mar 2014
    Posts
    27
    Thanks
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Image don't appear in the window.

    Hi, I Have a question and looking for suggestions if you can.

    I'm trying to load a maze, but I can't even show a single Image in the window.
    What I'm doing wrong?
    Qt Code:
    1. #include <QApplication>
    2. #include <QGraphicsView>
    3. #include <QGraphicsScene>
    4. #include <QGraphicsPixmapItem>
    5. #include <QMainWindow>
    6.  
    7.  
    8. int main(int argc, char *argv[])
    9. {
    10. QApplication a(argc, argv);
    11.  
    12. QGraphicsScene scene(-350, -350, 700, 700);
    13. QPixmap imagen("E:\Data\Pictures\PixelArt\60px-Brick.png");
    14. QGraphicsPixmapItem *newImagen = new QGraphicsPixmapItem(imagen);
    15. scene.addItem(newImagen);
    16. newImagen->setPos(5.0,5.0);
    17.  
    18. QGraphicsView *view= new QGraphicsView(&scene);
    19. view->show();
    20. return a.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 

    And if you got any suggestions on how to do load a maze, I already got one answer from an user, but if you got other suggestions, I'll appreciate it.
    Last edited by vitaR; 14th March 2014 at 06:04.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,641
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Image don't appear in the window.

    Line 13 is wrong. Escape the backslashes or use forward slashes.

Similar Threads

  1. Scaling window with image
    By danioto in forum Newbie
    Replies: 6
    Last Post: 20th October 2012, 13:58
  2. Replies: 3
    Last Post: 2nd March 2012, 02:59
  3. Image as window form
    By Ockonal in forum Qt Programming
    Replies: 5
    Last Post: 3rd April 2011, 09:16
  4. set backgorund image on main window
    By narumi in forum Newbie
    Replies: 3
    Last Post: 17th February 2008, 00:06
  5. Image without window frame?
    By niky in forum Qt Programming
    Replies: 6
    Last Post: 3rd February 2008, 09:37

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.