Results 1 to 7 of 7

Thread: how can i take an image from a specific part of my mainwindow and save it?

  1. #1
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default how can i take an image from a specific part of my mainwindow and save it?

    hi,
    is it possible to take a picture from a certain place of the MainWindow and save it? like printscreen but only a piece and certain place of my window must be in the picture.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how can i take an image from a specific part of my mainwindow and save it?


  3. The following user says thank you to d_stranz for this useful post:

    Alex22 (25th December 2015)

  4. #3
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how can i take an image from a specific part of my mainwindow and save it?

    Thanks d_stranz, I could save the entry of myMainWindow by under code:
    Qt Code:
    1. MainWindow *w;
    2. w = new MainWindow;
    3. QPixmap pixmap(w->size());
    4. w->render(&pixmap);
    5. pixmap.save("h.bmp");
    6. w->show();
    To copy to clipboard, switch view to plain text mode 

    I need to take an image from into the red box that you can see in the uploaded image. That the positions are:
    position 1: beginning of "GroupBox"
    position 2: top right of "b1"
    position 3: down left of "GroupBox"
    position 4: x=down left of "GroupBox", y=top right of "b1"

    thanks for any help about working with 4 above positions because the size of MainWindow can be changed by pulling the window.
    Screen.jpg

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how can i take an image from a specific part of my mainwindow and save it?

    If you only want the groupbox then call its render() method.

    If you need things across container widgets, render the widget that contains all and use QPixmap::copy() to extract the part you are interested in.

    Cheers,
    _

  6. #5
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how can i take an image from a specific part of my mainwindow and save it?

    Quote Originally Posted by anda_skoa View Post
    If you only want the groupbox then call its render() method.

    If you need things across container widgets, render the widget that contains all and use QPixmap::copy() to extract the part you are interested in.

    Cheers,
    _
    thanks. no i need the red box screen-shot that i draw in uploaded image and contains the GroupBox and 4 PushButttons(not just GroupBox). I told which positions are needed. please help me to do by those positions (4 positions that i told in my before post above).

  7. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how can i take an image from a specific part of my mainwindow and save it?

    You could put the buttons and the groupbox into a container widget and then render this widget.
    Or you just calculate the coordinates manually and use the already mentioned copy method.

    Cheers,
    _

  8. #7
    Join Date
    Nov 2015
    Posts
    128
    Thanks
    70
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: how can i take an image from a specific part of my mainwindow and save it?

    Quote Originally Posted by anda_skoa View Post
    You could put the buttons and the groupbox into a container widget and then render this widget.
    Or you just calculate the coordinates manually and use the already mentioned copy method.

    Cheers,
    _
    thanks anda, but sorry i am newbie in Qt. please give me an example

Similar Threads

  1. Replies: 15
    Last Post: 24th July 2015, 22:33
  2. Selecting a part of an image
    By haris_91 in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2015, 11:04
  3. Replies: 3
    Last Post: 3rd August 2012, 10:35
  4. Replies: 4
    Last Post: 29th May 2012, 23:37
  5. how to display specific part from website?
    By kholis in forum Newbie
    Replies: 0
    Last Post: 13th January 2011, 07:45

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.