Results 1 to 20 of 22

Thread: Qt Upgrade Repository..

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Upgrade Repository..

    Things become more weird now.
    Please refer to this video http://www.visionopen.com/qgraphicsview_paintevent2.ogv

    Now, after I changed my code a little bit to

    Qt Code:
    1. this->m_QTGraphicsScene->invalidate();
    2. this->repaint();
    To copy to clipboard, switch view to plain text mode 

    repaint() now is able to trigger paintEvent() as you can see from the above video file.
    However, no matter it's

    Qt Code:
    1. QPainter p(this);
    2. or
    3. QPainter p(this->viewport());
    To copy to clipboard, switch view to plain text mode 

    in function paintEvent(),
    I'm not able to display what has been drawn on the screen.

    The processed image have been successfully stored, but it just didn't show up on the screen.

    By the way, I guess why now paintEvent() was successfully triggered by
    Qt Code:
    1. this->repaint() ; // which was supposed to have the same functionality with this->update();
    To copy to clipboard, switch view to plain text mode 
    is just because I overwrote all qt 4.6.2 related .so files, and reconstruct the symbolic links to qt 4.6.3 .so files.

    We may neglect whether this is a qt 4.6.2 or qt 4.6.3 issue first.
    But, as you may noticed from the video of this time,
    paintEvent() is now successfully called whenever a new image is loaded (for processing),
    but paintEvent() just didn't really draw the image on the screen.

    Can you please help?

    Cheers
    JIA
    Last edited by jiapei100; 11th June 2010 at 05:02.
    Welcome to Vision Open
    http://www.visionopen.com

  2. #2
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Upgrade Repository..

    Now, I'm even able to Save the QImage out, and I can see the saving is absolutely correct.
    That is to say, I'm now very sure paintEvent causes this problem.

    After staring at the GUI application for quite a while, I found something interesting.
    It looks like paintEvent() did draw !!! But draw to a wrong position.
    Not quite sure, but see the attached two .png pictures.

    Images removed

    Pay attention to the very top left corner, there is little rectangle which has exactly the same color of my loaded image's background.
    Did you see?

    What could be the problem??

    Cheers
    JIA
    Last edited by wysota; 11th June 2010 at 09:28. Reason: Removed inline images, please use the attachment feature
    Welcome to Vision Open
    http://www.visionopen.com

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Upgrade Repository..

    Quote Originally Posted by jiapei100 View Post
    What could be the problem??
    The problem is in your code. You can be chasing ghosts all the time or you can just correct your code and forget about the problem. Your code is clearly incorrect. You lack understanding of how Graphics View and Qt's painting works but you keep pushing pretending you do understand it. The paint event of the viewport is not called because the scene doesn't change and Qt takes the rendering of the viewport from the backing store. If you invalidate the whole scene then contents of the backing store is marked dirty and the viewport is repainted using your event because Qt thinks there are some changes in the scene.

    repaint() and update() have different functionality - the first performs an immediate redraw, the other schedules one. A practical example:
    Qt Code:
    1. repaint();
    2. repaint();
    To copy to clipboard, switch view to plain text mode 
    will cause the paint event to be executed twice and
    Qt Code:
    1. update();
    2. update();
    To copy to clipboard, switch view to plain text mode 
    will cause the paint event to be executed once.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Upgrade Repository..

    wysota:

    You might be correct. I seriously have no idea how Qt's painting works. I dropped the question just to find the correct solution.
    You gave so much explanation but only without a solution.
    I'm wondering if you can afford me a direct solution, for example, affording an inherited class
    Qt Code:
    1. myQGraphicsView :: public QGraphicsView
    To copy to clipboard, switch view to plain text mode 
    and the demo code, which is really able to successfully display an QImage .

    By the way, I didn't pretend to do anything.
    If I pretend to be like that, I will never drop questions.
    The reason why I drop the question is just to let the whole world to know I'm not familiar with that,
    and I beg a solution sincerely.

    So, can you please help?
    All kinds of blame is of no use, compared to giving out a solution.

    Seriously hope you can give me a hand, by a solution to demonstrate you can do it.

    Looking forward to your solution.

    Best Regards
    JIA



    Quote Originally Posted by wysota View Post
    The problem is in your code. You can be chasing ghosts all the time or you can just correct your code and forget about the problem. Your code is clearly incorrect. You lack understanding of how Graphics View and Qt's painting works but you keep pushing pretending you do understand it. The paint event of the viewport is not called because the scene doesn't change and Qt takes the rendering of the viewport from the backing store. If you invalidate the whole scene then contents of the backing store is marked dirty and the viewport is repainted using your event because Qt thinks there are some changes in the scene.

    repaint() and update() have different functionality - the first performs an immediate redraw, the other schedules one. A practical example:
    Qt Code:
    1. repaint();
    2. repaint();
    To copy to clipboard, switch view to plain text mode 
    will cause the paint event to be executed twice and
    Qt Code:
    1. update();
    2. update();
    To copy to clipboard, switch view to plain text mode 
    will cause the paint event to be executed once.
    Welcome to Vision Open
    http://www.visionopen.com

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Upgrade Repository..

    Quote Originally Posted by jiapei100 View Post
    You gave so much explanation but only without a solution.
    I have no idea what you are doing so I can't give you a solution.
    If you want to display an image on Graphics View then either add it as an item to the scene or set it as the background brush of the scene (or reimplement drawBackground() if you need something more complex).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Upgrade Repository..

    Hi, wysota:

    I just want to show up an image using QGraphicsView widget.
    As you can see from here
    http://www.morethantechnical.com/200...ting-qwidgets/

    This guy successfully display something out by using

    Qt Code:
    1. this->update();
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. void FaceRecognizer::paintEvent(QPaintEvent* e) {
    2. QPainter painter(this);
    3. painter.drawImage(QPoint(ui.frame->x(),ui.frame->y()),m_i);
    4. ...
    5. }
    To copy to clipboard, switch view to plain text mode 

    He finally draw QImage m_i out at the position
    "QPoint(ui.frame->x(),ui.frame->y()" .

    Why he succeeded in doing this?

    BTW, I promise this website is not owned by me and we are absolutely different developers.
    So, according to your opinion, both of us succeeded in doing this but both of us are wrong, right?

    I believe you can realize your correct solution and demonstrate it now, just based upon the full code at
    http://www.morethantechnical.com/200...ting-qwidgets/

    Seriously hope you can give me a hand. Could be useful for that guy as well.

    Cheers
    JIA
    Welcome to Vision Open
    http://www.visionopen.com

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Upgrade Repository..

    "This guy" is not using graphics view.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Upgrade Repository..

    Hi, so, do you mean that
    if I inherit my class from QWidget, namely,

    revise
    Qt Code:
    1. class CqtImageView : public QGraphicsView
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. class CqtImageView : public QWidget
    To copy to clipboard, switch view to plain text mode 

    I should be able to make my code work, right??

    Thanks for your suggestion.
    And, could you please help to explain why QGraphicsView is not work?
    Because QGraphicsView is just a type of QWidget.

    Refer to the official documentation:

    http://doc.qt.nokia.com/4.6/qgraphicsview.html
    QGraphicsView<-QAbstractScrollArea<-QFrame<-QWidget.


    Best Regards
    JIA
    Welcome to Vision Open
    http://www.visionopen.com

  9. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Upgrade Repository..

    Quote Originally Posted by jiapei100 View Post
    I should be able to make my code work, right??
    Yes.

    And, could you please help to explain why QGraphicsView is not work?
    Because it's much more complex than a simple QWidget and it works in a different fashion.

    Because QGraphicsView is just a type of QWidget.

    Refer to the official documentation:

    http://doc.qt.nokia.com/4.6/qgraphicsview.html
    QGraphicsView<-QAbstractScrollArea<-QFrame<-QWidget.
    If you are so smart then why are you asking the questions and why is your code failing to work?

    BTW. you fail to see the difference between "subclass of" and "type of".

    Please just set the background brush for your scene as I told you if you want an immediate effect and then devote some time to study the documentation of graphics view architecture.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #10
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Upgrade Repository..

    I love you man !! hehe...
    Yes, you are right.
    Have to change the scene, instead of the view !
    Still not quite understand the whole theory at the back, but it works now.
    I'm using
    Qt Code:
    1. this->m_QTGraphicsScene->clear();
    2. this->m_QTGraphicsScene->addPixmap(QPixmap::fromImage(*this->m_QTImage));
    3. this->update();
    To copy to clipboard, switch view to plain text mode 
    after I reload a new image !

    And it seems I don't need to overload paintEvent() now.

    Not quite sure whether this is the right solution, but this works for me.
    The reason why I didn't want to use "addPixmap"
    is because it has to do a conversion from QImage to QPixmap,
    which I had guessed would slow down the process speed.


    Thanks wysota.

    Cheers
    JIA



    Quote Originally Posted by wysota View Post
    Yes.



    Because it's much more complex than a simple QWidget and it works in a different fashion.


    If you are so smart then why are you asking the questions and why is your code failing to work?

    BTW. you fail to see the difference between "subclass of" and "type of".

    Please just set the background brush for your scene as I told you if you want an immediate effect and then devote some time to study the documentation of graphics view architecture.
    Welcome to Vision Open
    http://www.visionopen.com

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt Upgrade Repository..

    If all you want is to show an image then why don't you just use QLabel? Graphics View is surely an overkill here.

    Qt Code:
    1. QLabel *label = new QLabel;
    2. label->setPixmap(QPixmap("myimage.png"));
    3. label->show();
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Sep 2009
    Location
    Surrey, BC, Canada
    Posts
    110
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt Upgrade Repository..

    Revised to QWidget and tested already.
    Same situation as using QGraphicsView.
    I'm now upgrading to 4.6.3 using KUbuntu's lauchpad .
    Let's see, how it goes.

    Best Regards
    JIA

    Quote Originally Posted by wysota View Post
    "This guy" is not using graphics view.
    Welcome to Vision Open
    http://www.visionopen.com

Similar Threads

  1. Qt Public Repository Launched!
    By lpotter in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2009, 00:38
  2. svn problem: help me clear the repository
    By magland in forum General Discussion
    Replies: 1
    Last Post: 26th September 2007, 01:54
  3. Up-to-date package repository?
    By sdfisher in forum Installation and Deployment
    Replies: 0
    Last Post: 21st July 2007, 19:25
  4. Icon repository
    By brcain in forum Newbie
    Replies: 2
    Last Post: 23rd February 2006, 18:04
  5. Is there a repository of widgets?
    By Mariane in forum Newbie
    Replies: 3
    Last Post: 20th January 2006, 07:40

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.