Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Screenshot of expanded combobox

Screenshot of expanded combobox

Scheduled Pinned Locked Moved Solved QML and Qt Quick
14 Posts 3 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Montjet

    Unfortunately, I also need popup in the screenshot :(

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #4

    @Montjet
    hi
    Could you try
    combo.popup.visible = true
    in Keys.onDigit1Pressed:
    https://stackoverflow.com/questions/38229511/how-to-open-combobox-dropdown-menu

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Montjet
      wrote on last edited by Montjet
      #5

      @mrjj said in Screenshot of expanded combobox:

      combo.popup.visible = true

      it doesn't work :(

      mrjjM 1 Reply Last reply
      0
      • M Montjet

        @mrjj said in Screenshot of expanded combobox:

        combo.popup.visible = true

        it doesn't work :(

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @Montjet
        Did you try anything else from the link ?
        To try to open it before the shot ?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Montjet
          wrote on last edited by Montjet
          #7

          Yes, I also tried to add parent of Popup:

          import QtQuick 2.9
          import QtQuick.Controls 2.2
          import QtQuick.Window 2.2
          
          Window
          {
              id: window
              visible: true
              width: 640
              height: 480
              title: qsTr("Hello World")
              Item
              {
                  id: root
                  anchors.fill: parent
                  focus: true
                  ComboBox
                  {
                      id: combo
                      width: 200
                      model: [ "First", "Second", "Third" ]
                      popup.parent: window.contentItem;
                      popup.modal: true;
                  }
                  Keys.onDigit1Pressed:
                  {
          
                     console.log("bbbb");
                      combo.popup.visible = true
                      root.grabToImage(function(result)
                                  {
                                      result.saveToFile("test.png");
                                      console.log("file has been saved");
                                  }, Qt.size(root.width, root.height));
                      combo.popup.visible = true
                  }
              }
          }
          

          Nothing works for me :(

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Montjet
            wrote on last edited by
            #8

            Oh, but this code works well:

            // ...
                        Window.contentItem.grabToImage(function(result)
                                    {
                                        result.saveToFile("test.png");
                                        console.log("file has been saved");
                                    }, Qt.size(root.width, root.height));
            // ...
            
            

            I need to take a screenshot of selected items, so my problem is still not resolved :(

            mrjjM GrecKoG 2 Replies Last reply
            0
            • M Montjet

              Oh, but this code works well:

              // ...
                          Window.contentItem.grabToImage(function(result)
                                      {
                                          result.saveToFile("test.png");
                                          console.log("file has been saved");
                                      }, Qt.size(root.width, root.height));
              // ...
              
              

              I need to take a screenshot of selected items, so my problem is still not resolved :(

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #9

              @Montjet
              Hmm
              Try with timer then
              http://doc.qt.io/qt-5/qml-qtqml-timer.html#details

              so set it high enough till u can open combo and select item and
              it should take shot with the dropdown visible.

              1 Reply Last reply
              0
              • M Montjet

                Oh, but this code works well:

                // ...
                            Window.contentItem.grabToImage(function(result)
                                        {
                                            result.saveToFile("test.png");
                                            console.log("file has been saved");
                                        }, Qt.size(root.width, root.height));
                // ...
                
                

                I need to take a screenshot of selected items, so my problem is still not resolved :(

                GrecKoG Offline
                GrecKoG Offline
                GrecKo
                Qt Champions 2018
                wrote on last edited by
                #10

                @Montjet said in Screenshot of expanded combobox:

                I need to take a screenshot of selected items, so my problem is still not resolved :(

                What's the problem ?
                When tested this seem to correctly grabs a screenshot of the opened combobox.
                What more do you want ?

                1 Reply Last reply
                1
                • M Offline
                  M Offline
                  Montjet
                  wrote on last edited by Montjet
                  #11

                  My main project is based on Qt 5.9.2.
                  For this solution I got error... :

                  QML QQuickRootItem: grabToImage: item has no QML engine
                  

                  It's difficult to solve this issue ;(

                  @GrecKo
                  Sometimes I need to take screenshot of a single rectangle that contains comboBox, not an entire window.

                  Example:

                  import QtQuick 2.9
                  import QtQuick.Controls 2.2
                  import QtQuick.Window 2.2
                  
                  Window
                  {
                      id: window
                      visible: true
                      width: 640
                      height: 480
                      title: qsTr("Hello World")
                      Item
                      {
                          id: root1
                          anchors.fill: parent
                          focus: true
                          ComboBox
                          {
                              id: combo1
                              width: 200
                              model: [ "First", "Second", "Third" ]
                              popup.parent: root1;
                              popup.modal: false;
                          }
                          Keys.onDigit1Pressed:
                          {
                  
                             console.log("bbbb");
                              combo1.popup.visible = true
                              window.contentItem.grabToImage(function(result)
                                          {
                                              result.saveToFile("test.png");
                                              console.log("file has been saved");
                                          }, Qt.size(root1.width, root1.height));
                              combo1.popup.visible = true
                          }
                      }
                  
                      Item
                      {
                          id: root2
                          anchors.fill: parent
                          focus: true
                          ComboBox
                          {
                              id: combo2
                              width: 200
                              model: [ "First", "Second", "Third" ]
                              popup.parent: root2;
                              popup.modal: false;
                              anchors.right: parent.right
                          }
                          Keys.onDigit2Pressed:
                          {
                  
                             console.log("bbbb");
                              combo2.popup.visible = true
                              window.contentItem.grabToImage(function(result)
                                          {
                                              result.saveToFile("test.png");
                                              console.log("file has been saved");
                                          }, Qt.size(root2.width, root2.height));
                              combo2.popup.visible = true
                          }
                      }
                  }
                  
                  

                  I want to take a screenshot of only one combobox.

                  1 Reply Last reply
                  0
                  • GrecKoG Offline
                    GrecKoG Offline
                    GrecKo
                    Qt Champions 2018
                    wrote on last edited by
                    #12

                    You want to screenshot only the combobox popup ?
                    Does that do what you want : combo1.popup.contentItem.grabToImage ?

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Montjet
                      wrote on last edited by Montjet
                      #13

                      I want to screenshot of root2 or root1.

                      Timer also doesn't work

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Montjet
                        wrote on last edited by Montjet
                        #14

                        Ok, I fixed it. I had older version of import QtQuick.Window -> 2.0

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved