PDA

View Full Version : Disable Move option in window



BalaQT
23rd December 2009, 05:42
hi,
Im using qt4.0 in debian. i want to disable the move in every window.
im using QDialog , QMainwindow. im using frameless window,but when i use alt+spacebar , i can able to move the window.
Is there any way to disable the move option

Thnks
Bala

high_flyer
23rd December 2009, 11:58
You can override the move event, and move the window back to its position every time it gets moved.

BalaQT
23rd December 2009, 14:08
Thnks for the reply

any examples pls

Bala

high_flyer
23rd December 2009, 14:12
read the documentation for QWidget::moveEvent()
http://doc.trolltech.com/4.5/qwidget.html#moveEvent

BalaQT
24th December 2009, 06:49
hi, highflyer,

i wrote the below code, idea is working but system was hanged .
any other ways to solve?

void MainWindow::moveEvent(QMoveEvent *event)
{
this->move(0,0);
}

Bala

yogeshgokul
24th December 2009, 07:26
hi, highflyer,
i wrote the below code, idea is working but system was hanged .
any other ways to solve?
Bala
Try this:

void MainWindow::moveEvent(QMoveEvent *event)
{
event->ignore();
}

BalaQT
25th December 2009, 05:50
hi yogesh
event.ignore() is not working. below is my code

void MainWindow::moveEvent(QMoveEvent *event)
{
event->ignore();
}

Thnks
Bala

Lykurg
25th December 2009, 08:37
come on, read the docs for move() and QMoveEvent! Work with QMoveEvent::oldPos() (As it is mentioned in the docs for QWidget::moveEvent()!!!)


And if you are not able to solve such an easy task, please use the Newbie section next time. We will help you also there...

BalaQT
26th December 2009, 05:49
hi lykurg,
Thnks for the reply. pls understand my question.
i have tried oldpos() and move(0,0),ignore()
but oldpos(),ignore() is not working completely.
move(0,0) is working but the system hangs on.

Below is my code


void MainWindow::moveEvent(QMoveEvent *event)
{
pos()=event->oldPos();
//event->ignore();
//this->move(0,0);
//this->pos().setX(0);
//this->pos().setY(0);
}


The control goes to moveevent when im moving the window. but im not getting the desired results.

how to disable the MOVE option in the MENU ,[which comes by pressing ALT-SPACEBAR] ?

I want to have a FIXED window, which cannot be moved.
pls direct me to solve this problem
Thnks
Bala

Lykurg
26th December 2009, 08:27
void XXX::moveEvent(QMoveEvent *event)
{
if (QPoint(100,100) != event->pos())
move(QPoint(100,100));
}

or you can use a frameless window.

BalaQT
27th December 2009, 06:37
Thnks Lykurg
Its working.
I want one more option.
since the EVENT places the form in new position,
the form is flickering while trying to MOVE. The window is fixed but flickering occurs.
Is there any way to Disable the MOVE option in the MENU [which comes by pressing ALT + SPACE BAR.]
My window is : Frameless MDI window.

im using the setWindowFlags(Qt::FramelessWindowHint);
But it will be helpful,if we can disable the MOVE option in the menu.

Thnks
Bala