Results 1 to 13 of 13

Thread: activate window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: activate window

    Pass 0 as the parent argument to the constructor. It's usually the last argument and it defaults to 0, so you might just skip it.

    Your code needs major changes, by the way... I see at least two incorrect approaches there.

  2. #2
    Join Date
    Feb 2008
    Location
    Porbandar
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: activate window

    I had also tried to pass zero in two different ways as below:

    MyWidget ( int r, Qimage image QWidget *parent =0);

    MyWidget( QWidget * parent=0, Qt::WindowFlags f=0 );

    Further i tried alot to activate using Activate Window but failed to do so..
    thanx for taking interest..
    will you please tell me @ simple way to just activate that window as t\o have mouse events?

  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: activate window

    You don't need any special treatment to receive mouse events. A window is active when you click on it or call QApplication::setActiveWindow(). How come you know you don't receive events for the widget?

  4. #4
    Join Date
    Feb 2008
    Location
    Porbandar
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: activate window

    by printing mouse event position( which are not getting printed) as well as isActive Window boolian function ( which returns false)

  5. #5
    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: activate window

    Ok, let's start from the beginning - what is the final effect you are trying to obtain? Try to be as precise in explaining as you can, this will allow us to solve the problem faster. I see you are doing something with some image and you want to do rubberbanding but it's not clear for me how this blends together...

    By the way - "not getting printed" doesn't yet mean "not getting executed"...

  6. #6
    Join Date
    Feb 2008
    Location
    Porbandar
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: activate window

    thanx. To begin with the objective is something like this:
    i have prepared one GUI by Qt Designer, Clicking on one menu named "work1" of its menu bar, should open one another window, which contains scanned image of of a picture,say of 20 persons . On which i have drawn certain editable boxes around these individual person using QRubberband. I should be able to edit those rubberband boxes of that window.

    Let me clarify more that without using GUI , i m able to show and edit those rubberbanded boxes using mouse.My program runs absolutely good without GUI linking.

    But after linking it to GUI , some where some thing goes wrong, every thing works fine except that " this window falls behind the GUI window. So it is clear that there seems to be problem in linking, or calling or constructors or priority may be any thing like that.

    Now i hope I have made to understand my objective and problem....!

    So i tried to activate and bring front that window but I failed in that case only...


    Regarding yr query of mouse events:
    I have used following code to see if mouse events occur.
    Qt Code:
    1. void MyWidget::mousePressEvent(QMouseEvent *event)
    2. {
    3. origin = event->pos();
    4. cout<<"x event "<< event->x()<<"y event "<< event->y()<<endl;}
    To copy to clipboard, switch view to plain text mode 
    Perhaps today i have disturbed u alot.....! Thnx for guidance..
    Last edited by jpn; 30th April 2008 at 07:31. Reason: missing [code] tags

  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

    Angry Re: activate window

    Quote Originally Posted by parmar ranjit View Post
    thanx. To begin with the objective is something like this:
    i have prepared one GUI by Qt Designer, Clicking on one menu named "work1" of its menu bar, should open one another window, which contains scanned image of of a picture,say of 20 persons . On which i have drawn certain editable boxes around these individual person using QRubberband. I should be able to edit those rubberband boxes of that window.
    Ok, seems simple enough...

    So it is clear that there seems to be problem in linking, or calling or constructors or priority may be any thing like that.
    Or overall code design and understanding of Qt

    So i tried to activate and bring front that window but I failed in that case only...
    Let's clearly state what we have. Do you actually have two windows? With separate title bars, etc.? Can you move them around on your screen?


    Regarding yr query of mouse events:
    I have used following code to see if mouse events occur.
    void MyWidget::mousePressEvent(QMouseEvent *event)
    {
    origin = event->pos();
    cout<<"x event "<< event->x()<<"y event "<< event->y()<<endl;}
    This would be more convincing:
    Qt Code:
    1. void MyWidget::mousePressEvent(QMouseEvent *event){
    2. QMessageBox::information(this, "Click!", QString("Click occured at %1x%2").arg(event->pos().x()).arg(event->pos().y()));
    3. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Feb 2008
    Location
    Porbandar
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: activate window

    oh Thnx indeed ...
    I have been able to cop up with the problem using QDialog and setModal

    Again thank you very much
    Ranjit

Similar Threads

  1. Set a window as child at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 26th November 2007, 09:30
  2. Replies: 3
    Last Post: 23rd November 2007, 11:40
  3. Change shape of window / animate window
    By sabeesh in forum Qt Programming
    Replies: 3
    Last Post: 31st October 2007, 08:16
  4. Regarding drawing on Transparent Window
    By Shalabh in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2007, 10:32
  5. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41

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.