View Full Version : Resize QDeclarativeView
Globulus
28th August 2011, 18:17
Hi everyone!
I have a transparent frameless QDeclarativeView based window
I use
MyWidgetMainWindow w;
w.setWindowFlags(Qt::FramelessWindowHint) ;
w.setAttribute(Qt::WA_TranslucentBackground);
w.setStyleSheet("background:transparent");
How can I resize it?
Something like a QSizeGrip or what?
How can I put it on the left bottom of my window?
wysota
29th August 2011, 07:00
Moving widgets
Globulus
29th August 2011, 16:58
I have no problems with moving my window, I want to
have an opportunity to resize it!
Here is my code:
myprog.h
#include <QtGui>
#include <QtDeclarative>
class MyProg : public QDeclarativeView
{
Q_OBJECT
public:
MyProg(QWidget *parent = 0);
~MyProg();
Q_INVOKABLE void moveWindow(int x,int y, int, int);
};
myprog.cpp
#include "myprog.h"
MyProg::MyProg(QWidget *parent)
// : QWidget(parent,0)
: QDeclarativeView(parent)
{
rootContext()->setContextProperty("mainwnd",this);
setResizeMode(QDeclarativeView::SizeRootObjectToVi ew);
setSource(QUrl("qml/main.qml"));
}
MyProg::~MyProg()
{
}
void MyProg::moveWindow(int x,int y, int lx, int ly)
{
QPoint p = mapToGlobal(QPoint(x,y));
p.setX(p.x() - lx);
p.setY(p.y() - ly);
this->move(p);
}
main.cpp
#include <QtGui/QApplication>
#include "myprog.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyProg w;
w.setWindowFlags(Qt::FramelessWindowHint) ;
w.setAttribute(Qt::WA_TranslucentBackground);
w.setStyleSheet("background:transparent");
w.show();
return a.exec();
}
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.
wysota
29th August 2011, 17:31
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?
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.