Results 1 to 4 of 4

Thread: my QGraphicView problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Posts
    8
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default my QGraphicView problem


    Hi,
    I used the code below normally in QApplication

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. QPixmap pix;
    5. //QImage image;
    6. QString currentFile = QFileDialog::getOpenFileName(0,"Open File", QDir::currentPath());
    7. QImage image(currentFile);
    8. //pix.load(":/Resources/open.png");
    9. //pix.load(currentFile);
    10.  
    11. scene.addPixmap(QPixmap::fromImage(image));
    12. gr= new QGraphicsView();
    13. gr->setScene(&scene);
    14. //setCentralWidget(gr);
    15. gr->show();
    16.  
    17. return a.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

    and this works. I can see the image loaded.

    But when I used the same code in QMainWindow
    such as

    Qt Code:
    1. deneme::deneme(QWidget *parent, Qt::WFlags flags)
    2. : QMainWindow(parent, flags)
    3. {
    4. ui.setupUi(this);
    5. QPixmap pix;
    6. //QImage image;
    7. QString currentFile = QFileDialog::getOpenFileName(0,"Open File", QDir::currentPath());
    8. QImage image(currentFile);
    9.  
    10. scene.addPixmap(QPixmap::fromImage(image));
    11. gr= new QGraphicsView();
    12. //gr->setBackgroundBrush(QImage(currentFile));
    13. //gr->setForegroundBrush(QImage(currentFile));
    14. gr->setScene(&scene);
    15. //setCentralWidget(gr);
    16. gr->show();
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 
    this does not work. And I can only see white graphics widget when I loaded the image.

    How can I solve this problem. Thanks in advance
    regards
    Last edited by jpn; 21st July 2008 at 16:58. Reason: changed [b] to [code] tags

Similar Threads

  1. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  2. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  3. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52
  4. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.