Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. My custom QML item always have the size of the window

My custom QML item always have the size of the window

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmlc++
2 Posts 2 Posters 331 Views
  • 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.
  • L Offline
    L Offline
    lucaszanella
    wrote on last edited by lucaszanella
    #1

    My custom C++ QML item is called OpenGlVideoQtQuick

    import QtQuick 2.0
    import A 1.0
    Item {
        width: 1280
        height: 720
        OpenGlVideoQtQuick {
                width: 640
                height: 480
                uri: "rtsp://admin:123456@192.168.0.103:10554/tcp/av0_0"
            }
    }
    

    Here's its interface:

    class OpenGlVideoQtQuick : public QQuickItem
    {
        Q_OBJECT
        Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
    
    public:
        OpenGlVideoQtQuick();
    
        QString uri;
    
        qreal t() const { return m_t; }
        void setT(qreal t);
    
    signals:
        void tChanged();
    
    public slots:
        void sync();
        void cleanup();
        void update();//Updates the window
    
    
    private slots:
        void handleWindowChanged(QQuickWindow *win);
    
    private:
        qreal m_t;
        OpenGlVideoQtQuickRenderer *openGlVideoQtQuickRenderer;
    
    };
    

    Even if I explicitly say that it should have the size 640x480, inside an item of size 1280x720, it always gets the size of the entire screen, which is 1280x720.

    What am I doing wrong?

    S 1 Reply Last reply
    0
    • L lucaszanella

      My custom C++ QML item is called OpenGlVideoQtQuick

      import QtQuick 2.0
      import A 1.0
      Item {
          width: 1280
          height: 720
          OpenGlVideoQtQuick {
                  width: 640
                  height: 480
                  uri: "rtsp://admin:123456@192.168.0.103:10554/tcp/av0_0"
              }
      }
      

      Here's its interface:

      class OpenGlVideoQtQuick : public QQuickItem
      {
          Q_OBJECT
          Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
      
      public:
          OpenGlVideoQtQuick();
      
          QString uri;
      
          qreal t() const { return m_t; }
          void setT(qreal t);
      
      signals:
          void tChanged();
      
      public slots:
          void sync();
          void cleanup();
          void update();//Updates the window
      
      
      private slots:
          void handleWindowChanged(QQuickWindow *win);
      
      private:
          qreal m_t;
          OpenGlVideoQtQuickRenderer *openGlVideoQtQuickRenderer;
      
      };
      

      Even if I explicitly say that it should have the size 640x480, inside an item of size 1280x720, it always gets the size of the entire screen, which is 1280x720.

      What am I doing wrong?

      S Offline
      S Offline
      sharath
      wrote on last edited by sharath
      #2

      @lucaszanella HI,

      I really don't know that what exactly happening in your code.
      Just try parenting approach.
      width:parent * 0.75
      height:parent * 0.55

      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