Results 1 to 4 of 4

Thread: Resize QDeclarativeView

  1. #1
    Join Date
    Aug 2011
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Resize QDeclarativeView

    Hi everyone!
    I have a transparent frameless QDeclarativeView based window
    I use
    Qt Code:
    1. MyWidgetMainWindow w;
    2. w.setWindowFlags(Qt::FramelessWindowHint) ;
    3. w.setAttribute(Qt::WA_TranslucentBackground);
    4. w.setStyleSheet("background:transparent");
    To copy to clipboard, switch view to plain text mode 

    How can I resize it?
    Something like a QSizeGrip or what?
    How can I put it on the left bottom of my window?

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

    Default Re: Resize QDeclarativeView

    [wiki]Moving widgets[/wiki]
    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.


  3. #3
    Join Date
    Aug 2011
    Posts
    10
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Resize QDeclarativeView

    I have no problems with moving my window, I want to
    have an opportunity to resize it!
    Here is my code:
    myprog.h
    Qt Code:
    1. #include <QtGui>
    2. #include <QtDeclarative>
    3.  
    4.  
    5. class MyProg : public QDeclarativeView
    6. {
    7. Q_OBJECT
    8.  
    9. public:
    10. MyProg(QWidget *parent = 0);
    11. ~MyProg();
    12.  
    13. Q_INVOKABLE void moveWindow(int x,int y, int, int);
    14.  
    15.  
    16. };
    To copy to clipboard, switch view to plain text mode 

    myprog.cpp

    Qt Code:
    1. #include "myprog.h"
    2.  
    3. MyProg::MyProg(QWidget *parent)
    4. // : QWidget(parent,0)
    5. : QDeclarativeView(parent)
    6. {
    7.  
    8.  
    9. rootContext()->setContextProperty("mainwnd",this);
    10. setResizeMode(QDeclarativeView::SizeRootObjectToView);
    11. setSource(QUrl("qml/main.qml"));
    12.  
    13.  
    14.  
    15. }
    16.  
    17. MyProg::~MyProg()
    18. {
    19.  
    20. }
    21.  
    22. void MyProg::moveWindow(int x,int y, int lx, int ly)
    23. {
    24. QPoint p = mapToGlobal(QPoint(x,y));
    25. p.setX(p.x() - lx);
    26. p.setY(p.y() - ly);
    27. this->move(p);
    28. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "myprog.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6.  
    7. QApplication a(argc, argv);
    8.  
    9.  
    10. MyProg w;
    11.  
    12.  
    13. w.setWindowFlags(Qt::FramelessWindowHint) ;
    14. w.setAttribute(Qt::WA_TranslucentBackground);
    15. w.setStyleSheet("background:transparent");
    16.  
    17.  
    18.  
    19.  
    20.  
    21. w.show();
    22.  
    23. return a.exec();
    24. }
    To copy to clipboard, switch view to plain text mode 

    It seems to me, that I must catch the press button event in qml code first, and then calculate QDeclarativeView window geometry in my cpp code...
    something like that,I think.

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

    Default Re: Resize QDeclarativeView

    Quote Originally Posted by Globulus View Post
    I have no problems with moving my window, I want to
    have an opportunity to resize it!
    That's great. If I give you code that resizes the window down, will you say that you want code that resizes the window both up and down or will you just take a look at the code and implement the missing piece yourself using a similar approach?
    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.


Similar Threads

  1. Replies: 2
    Last Post: 16th July 2011, 12:39
  2. Replies: 0
    Last Post: 12th July 2011, 08:20
  3. Using QDeclarativeView::Show()
    By proj_symbian in forum Qt Quick
    Replies: 17
    Last Post: 30th May 2011, 19:26
  4. Replies: 1
    Last Post: 9th May 2011, 20:45
  5. Replies: 2
    Last Post: 9th May 2011, 02:04

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.