Results 1 to 3 of 3

Thread: Position of QMessageBox

  1. #1
    Join Date
    Apr 2012
    Posts
    43
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default Position of QMessageBox

    I quite dont understand this issue. I have this part of code:

    Qt Code:
    1. x=500;
    2. y=500;
    3. message->move(x,y);
    4. message->exec();
    5. r=p11manipulator->thread.functionReturned;
    6.  
    7. if(!r)
    8. {
    9. message->move(x,y);
    10. message->exec();
    To copy to clipboard, switch view to plain text mode 

    message is created in constructor of my class with message = new QMessageBox(this); and "this" is QMainWindow. When I call message->exec() for the first time, it is placed somewhere (500,500 i hope), but for the second time, it jumps slightly higher. Why is that?

  2. #2
    Join Date
    Jul 2012
    Posts
    40
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    12
    Thanked 1 Time in 1 Post

    Default Re: Position of QMessageBox

    Don't create a QMessageBox in Construcor of your MainWin....

  3. #3
    Join Date
    Jun 2012
    Posts
    98
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    11

    Default Re: Position of QMessageBox

    If you're going to call it at the start of the code (and also somewhere else) wrap the thing in a function and go from there.

    If it's still moving then IIRC you can pass a QPoint to the .exec command to have it pop up where you want. I do this for menus so they pop up where my cursor is instead of in the same position all the time.

Similar Threads

  1. How to get Qmessagebox output?
    By Gokulnathvc in forum Newbie
    Replies: 3
    Last Post: 25th March 2011, 10:53
  2. QMessageBox
    By sonuani in forum Qt Programming
    Replies: 13
    Last Post: 2nd September 2009, 18:56
  3. QMessageBox
    By sonuani in forum Qt Programming
    Replies: 1
    Last Post: 31st March 2008, 09:27
  4. Re: Help on QMessageBox
    By arunvv in forum Newbie
    Replies: 2
    Last Post: 26th March 2008, 00:45
  5. how to use tr() for QMessageBox?
    By gfunk in forum Qt Programming
    Replies: 4
    Last Post: 17th November 2007, 12:30

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
  •  
Qt is a trademark of The Qt Company.