PDA

View Full Version : Disable resize events



myrky
23rd June 2009, 22:24
Hello, my application use a flash based interface as qwidget and i have a qwebview dialog as child window. When i load a website who ask a resize of mainwindow my flash interface is rezised to a small value and i dont want a resize. How can i disable resize event on my mainwindow.

I tried setFixedSize() , setSizePolicy() and they cant disable resize event.

gsmiko
23rd June 2009, 23:41
Hi myrky!

To use a fixed size window, you have to set the minimum and maximum size of the window to the same size, and set size policy to fixed. This can either be done from QtDesigner or from code. For example to limit the size of your window to 300x300:

QSize fixedSize(300,300);
setMinimumSize(fixedSize);
setMaximumSize(fixedSize);
setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixe d);

To disable resize events, you have to reimplement the resizeEvent virtual function in your subclass of QWidget and ignore the resize event... , but I think it's the previous solution is what you're looking for.

wysota
24th June 2009, 01:08
When i load a website who ask a resize of mainwindow my flash interface is rezised to a small value and i dont want a resize.

Can you elaborate on what you mean by the website wanting to resize your main window?

myrky
25th June 2009, 14:23
Can you elaborate on what you mean by the website wanting to resize your main window?

Ok, when i open a url i lauch an application from it and this application resize my main windows (my flash interface). But i disabled it using this
QSize fixedSize(1920,1200);
setMinimumSize(fixedSize);
setMaximumSize(fixedSize);
setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixe d);

The application resize my main window instead. I dont know how to prevent it.

gsmiko
25th June 2009, 15:56
No offense, but to be honest myrky I don't understand your problem exactly either. Some samples from your code and some screenshots would be useful.

myrky
25th June 2009, 17:42
My problem is when my application is in fullscreen mode my mainwindow can be resized by another application. If it not in fullscreen this work good.

wysota
25th June 2009, 23:10
What other application? What does WebKit has to do with it?

myrky
26th June 2009, 13:49
I use webkit in my application, when i open a website there is javascript who resize my mainwindow. Here the javascript :
<script language="javascript">
function SetWindowSize(w,h) {
var screenH = screen.height;
var screenW = screen.width;
if (window.navigator.appName=="Netscape") {
if (window.navigator.userAgent.indexOf("Firefox") != -1) {
window.resizeTo(w,h - 90);
} else if(window.navigator.userAgent.indexOf("Netscape") != -1) {
window.resizeTo(w,h - 112);
} else {
window.resizeTo(w,h - 112);
}
} else {
window.resizeTo(w,h - 112);
}
window.moveTo((screenW-w)/2,(screenH-h)/2);
}

</script>

<SCRIPT LANGUAGE = "JavaScript">
var dom = document.getElementById?1:0;
var NS4 = (document.layers && !dom )? 1:0;

// do for ns4 resize problem
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if (false) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
if(NS4)
MM_reloadPage(true);
</SCRIPT>

I can setup my windows to avoid resizing if my application is not in full screen by using that code :
QSize fixedSize(1920,1200);
setMinimumSize(fixedSize);
setMaximumSize(fixedSize);
setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixe d);

But this don't work in fullscreen mode.

I want to disable resizing from that javascript.