Results 1 to 11 of 11

Thread: File icon to graphic view

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: File icon to graphic view

    This:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent), ui(new Ui::MainWindow)
    3. {
    4. ui->setupUi(this);
    5. gv = new QGraphicsView(this);
    6. setCentralWidget(gv);
    7. QGraphicsScene *scene = new QGraphicsScene(gv);
    8. scene->setSceneRect(0, 0, 500, 500);
    9. gv->setScene(scene);
    10.  
    11. QGraphicsRectItem *ritem = new QGraphicsRectItem(scene->sceneRect());
    12. scene->addItem(ritem);
    13.  
    14. // first way to add a pixmap
    15. QGraphicsPixmapItem *pitem = new QGraphicsPixmapItem(QPixmap(":/img/Save.png"));
    16. scene->addItem(pitem);
    17. pitem->setPos(100, 100);
    18.  
    19. // second way
    20. scene->addPixmap(QPixmap(":/img/Find.png"))->setPos(200, 200);
    21. }
    To copy to clipboard, switch view to plain text mode 
    will result in this:
    Attached Images Attached Images
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. Dropping file over app icon in MAC
    By dev_maximaa in forum Qt Programming
    Replies: 0
    Last Post: 20th March 2009, 06:40
  2. Obtaining a Windows file icon using fromWinHBITMAP()
    By DIMEDROLL in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2008, 12:50
  3. Setting OS Specified Icon on the File?
    By vishal.chauhan in forum Qt Programming
    Replies: 4
    Last Post: 31st May 2008, 13:37
  4. Set QApplication icon without using the rc/qrc file ?
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 23rd March 2007, 16:06
  5. set Icon to .app file
    By vishal.chauhan in forum Qt Programming
    Replies: 2
    Last Post: 10th January 2007, 22:13

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
  •  
Qt is a trademark of The Qt Company.