Results 1 to 8 of 8

Thread: Disable resize events

  1. #1
    Join Date
    Jun 2009
    Posts
    12

    Default Disable resize events

    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.

  2. #2
    Join Date
    Sep 2008
    Posts
    25
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Disable resize events

    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:
    Qt Code:
    1. QSize fixedSize(300,300);
    2. setMinimumSize(fixedSize);
    3. setMaximumSize(fixedSize);
    4. setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    To copy to clipboard, switch view to plain text mode 

    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.

  3. #3
    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: Disable resize events

    Quote Originally Posted by myrky View Post
    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?
    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.


  4. #4
    Join Date
    Jun 2009
    Posts
    12

    Default Re: Disable resize events

    Quote Originally Posted by wysota View Post
    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
    Qt Code:
    1. QSize fixedSize(1920,1200);
    2. setMinimumSize(fixedSize);
    3. setMaximumSize(fixedSize);
    4. setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    To copy to clipboard, switch view to plain text mode 

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

  5. #5
    Join Date
    Sep 2008
    Posts
    25
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Disable resize events

    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.

  6. #6
    Join Date
    Jun 2009
    Posts
    12

    Default Re: Disable resize events

    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.

  7. #7
    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: Disable resize events

    What other application? What does WebKit has to do with it?
    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.


  8. #8
    Join Date
    Jun 2009
    Posts
    12

    Default Re: Disable resize events

    I use webkit in my application, when i open a website there is javascript who resize my mainwindow. Here the javascript :
    Qt Code:
    1. <script language="javascript">
    2. function SetWindowSize(w,h) {
    3. var screenH = screen.height;
    4. var screenW = screen.width;
    5. if (window.navigator.appName=="Netscape") {
    6. if (window.navigator.userAgent.indexOf("Firefox") != -1) {
    7. window.resizeTo(w,h - 90);
    8. } else if(window.navigator.userAgent.indexOf("Netscape") != -1) {
    9. window.resizeTo(w,h - 112);
    10. } else {
    11. window.resizeTo(w,h - 112);
    12. }
    13. } else {
    14. window.resizeTo(w,h - 112);
    15. }
    16. window.moveTo((screenW-w)/2,(screenH-h)/2);
    17. }
    18.  
    19. </script>
    20.  
    21. <SCRIPT LANGUAGE = "JavaScript">
    22. var dom = document.getElementById?1:0;
    23. var NS4 = (document.layers && !dom )? 1:0;
    24.  
    25. // do for ns4 resize problem
    26. function MM_reloadPage(init) { //reloads the window if Nav4 resized
    27. if (init==true) with (navigator) {if (false) {
    28. document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
    29. else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    30. }
    31. if(NS4)
    32. MM_reloadPage(true);
    33. </SCRIPT>
    To copy to clipboard, switch view to plain text mode 

    I can setup my windows to avoid resizing if my application is not in full screen by using that code :
    Qt Code:
    1. QSize fixedSize(1920,1200);
    2. setMinimumSize(fixedSize);
    3. setMaximumSize(fixedSize);
    4. setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    To copy to clipboard, switch view to plain text mode 

    But this don't work in fullscreen mode.

    I want to disable resizing from that javascript.

Similar Threads

  1. QGraphicsView Mouse Events
    By tomf in forum Qt Programming
    Replies: 5
    Last Post: 29th July 2008, 15:03
  2. Double click resize window disable
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 13th May 2008, 11:35
  3. Replies: 2
    Last Post: 22nd January 2008, 16:10
  4. Custom Shape Widget (resize)
    By PiXeL16 in forum Qt Programming
    Replies: 7
    Last Post: 12th February 2007, 07:00
  5. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 00:32

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.