Results 1 to 20 of 21

Thread: Limit Window Movement

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Limit Window Movement

    I find that if I use it in just a mainwindow it will work fine. But as soon as that main window gets a frame in it the dialog will fail to stop at the border. I have been trying to figure it out and I just am confused right now.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: Limit Window Movement

    Well, could you post the code in question?

  3. #3
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Limit Window Movement

    Before I try to post all the code, (cause I am not sure what code is causing the issue) is there a way just to stop the mouse from having focus on the dialog box?

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: Limit Window Movement

    You could try disabling it by calling setFocusPolicy(Qt::NoFocus) in the dialog constructor, but I don't guarantee it will do too much.

  5. #5
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Limit Window Movement

    alright...I am running out of ideas. I didn't think this would be this difficult. Other then the code I already posted here is the other code.

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    lockedarea w;
    w.show();
    a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
    return a.exec();
    }
    lockedarea::lockedarea(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
    {
    ui.setupUi(this);
    tmp *Tmp = new tmp(this);
    Tmp->show();
    }

    lockedarea::~lockedarea()
    {

    tmp::tmp(QWidget *parent)
    : LimitMovement(parent)
    {
    ui.setupUi(this);
    //this->move(parent->pos());
    mmm *ccc = new mmm(parent);
    ccc->show();

    }

    tmp::~tmp()
    {

    }
    mmm::mmm(QWidget *parent)
    : LimitMovement(parent)
    {
    ui.setupUi(this);
    }

    mmm::~mmm()
    {

    }

    LimitMovement::LimitMovement(QWidget *parent)
    : QWidget()//parent)
    {
    parentSize = parent->frameGeometry().size();
    parentPosition = parent->pos();
    this->move(parentPosition.x()+(parentSize.width()/2),
    parentPosition.y()+(parentSize.height()/2));
    }





    ---That's all my code...there isn't much to the dialogs

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Limit Window Movement

    How about a completely different approach? Because window frames including titlebar are not handled by Qt but the underlying system, how about implementing a custom titlebar to get full control over window movement?
    J-P Nurmi

  7. The following user says thank you to jpn for this useful post:

    abbapatris (19th July 2007)

  8. #7
    Join Date
    Jun 2007
    Posts
    52
    Thanks
    6

    Default Re: Limit Window Movement

    Thats a very good idea. Is there a tutorial or some documentation that could help with this that you know of?

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Limit Window Movement

    Quote Originally Posted by abbapatris View Post
    Is there a tutorial or some documentation that could help with this that you know of?
    Try following Brandybuck's suggestion:
    http://www.qtcentre.org/forum/f-qt-p...s-3975.html#10
    J-P Nurmi

Similar Threads

  1. Replies: 4
    Last Post: 4th June 2007, 12:07
  2. Regarding drawing on Transparent Window
    By Shalabh in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2007, 10:32
  3. Independant window in an application
    By titoo in forum Qt Programming
    Replies: 4
    Last Post: 28th February 2007, 11:07
  4. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 10:21

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.