Results 1 to 13 of 13

Thread: grabWidget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default grabWidget

    Hi,
    I need to grab only my QGLWidget. but grabWidget take only QWidget?
    This below grab only a gray square!
    Qt Code:
    1. QPixmap qp = QPixmap::grabWidget(myGLWidget, 0,0, -1, -1);
    To copy to clipboard, switch view to plain text mode 
    Is there a way or I must use grabWindow?
    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: grabWidget

    Use QGLWidget::renderPixmap().

  3. #3
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: grabWidget

    the problem of this function is that (I read) will start initalizeGL, paintGL() etc...and after this call my contextGL() changes! There are some problem. I don't know if are there ways to avoid this...

    I tried use grabWindow.it grab all widget are on my interest widget But very problem of this is that it grab also a QMessageBox::warning that is launched a bit before of grabbing. How can I avoid this?

    Thanks
    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: grabWidget

    Quote Originally Posted by mickey
    the problem of this function is that (I read) will start initalizeGL, paintGL() etc...and after this call my contextGL() changes! There are some problem. I don't know if are there ways to avoid this...
    Why do you want avoid this? If you implement these methods properly you shouldn't have any problems.

    Quote Originally Posted by mickey
    I tried use grabWindow.it grab all widget are on my interest widget But very problem of this is that it grab also a QMessageBox::warning that is launched a bit before of grabbing. How can I avoid this?
    In Qt3 QGLWidget bypasses the Qt painting engine, so you must use QGLWidget::renderPixmap(). You can also try to make a screenshot.

  5. #5
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: grabWidget

    Quote Originally Posted by jacek
    Why do you want avoid this? If you implement these methods properly you shouldn't have any problems.
    my texture are destroyed after renderPixmap! If I use grabWindow this not happen.....
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: grabWidget

    Quote Originally Posted by mickey
    my texture are destroyed after renderPixmap! If I use grabWindow this not happen.....
    How do you initialize those textures?

  7. #7
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: grabWidget

    yes, in initalializeGL()
    Regards

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: grabWidget

    Quote Originally Posted by mickey
    yes, in initalializeGL()
    But how do you initialize those textures?

  9. #9
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: grabWidget

    Qt Code:
    1. //initializeGL()
    2. per.myinitGL();
    3. glEnable(GL_TEXTURE_2D);
    4. glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
    5. glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
    6. glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    7. glDisable(GL_TEXTURE_2D);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. perc::myInitGL() {
    2. glGenTextures(1, &tex);
    3. QImage img;
    4. if ( !img.load(texFileName)) {
    5. QImage buf;
    6. buf.fill(Qt::gray.rgb() );
    7. img=buf;
    8. }
    9. QImage tx = QGLWidget::convertToGLFormat (img);
    10. glBindTexture(GL_TEXTURE_2D, tex);
    11. gluBuild2DMipmaps(GL_TEXTURE_2D, 3, tx.width(), tx.height(), GL_RGBA, GL_UNSIGNED_BYTE, tx.bits() );
    12. }
    To copy to clipboard, switch view to plain text mode 
    Is it ok? It seems works properly....
    Regards

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: grabWidget

    Quote Originally Posted by mickey
    Is it ok? It seems works properly....
    Every time initializeGL() is called, per.myinitGL() will overwrite the tex variable. Maybe it will be enough, if you check whether initializeGL() is called for the first time and only then call per.myinitGL()?

    What is that "per" object?

  11. #11
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: grabWidget

    'per' is my object on I put texture...a square; Are you saying me that when I call renderpixmap(), initializeGL() starts and tex is overwrite? (But tex should be the same before......).
    But what is the advantage for renderPixmap() of re-call initializeGL and PaintGL()? Isn't it a time lose?
    Regards

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.