Results 1 to 10 of 10

Thread: Align QDialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Align QDialog

    use
    Qt Code:
    1. dialog->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, dialog->size(), qApp->desktop()->availableGeometry()));
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Default Re: Align QDialog

    Quote Originally Posted by Lykurg View Post
    use
    Qt Code:
    1. dialog->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, dialog->size(), qApp->desktop()->availableGeometry()));
    To copy to clipboard, switch view to plain text mode 
    It works perfectly. Thank you.

  3. #3
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Default Re: Align QDialog

    Quote Originally Posted by Lykurg View Post
    use
    Qt Code:
    1. dialog->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, dialog->size(), qApp->desktop()->availableGeometry()));
    To copy to clipboard, switch view to plain text mode 
    Is there any way to set the size of QDialog that function?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Align QDialog

    substitute dialog->size() with any size (QSize) you want.

  5. #5
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Default Re: Align QDialog

    Quote Originally Posted by Lykurg View Post
    substitute dialog->size() with any size (QSize) you want.
    I did the following:

    this->setGeometry(QStyle::alignedRect(Qt::LeftToRight , Qt::AlignCenter, 88, qApp->desktop()->availableGeometry()));

    But he gave me the following error:

    /Users/danielsousa/Qt/Interface-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Release/../Interface2/criareditaralerta.cpp:15: error: no matching function for call to 'QStyle::alignedRect(Qt::LayoutDirection, Qt::AlignmentFlag, int, const QRect)'

  6. #6
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: Align QDialog

    yea well, 88 is an int, not a QSize. And there is no QSize implicit constructor with an single int as argument
    The error message is quite explicit btw

  7. #7
    Join Date
    Apr 2012
    Posts
    39
    Thanks
    7

    Default Re: Align QDialog

    Quote Originally Posted by totem View Post
    yea well, 88 is an int, not a QSize. And there is no QSize implicit constructor with an single int as argument
    The error message is quite explicit btw
    Yeah, but then how can I fix this?

  8. #8
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: Align QDialog

    consider this a minute.
    In the previous version, you wrote
    Qt Code:
    1. dialog->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, dialog->size(), qApp->desktop()->availableGeometry()));
    To copy to clipboard, switch view to plain text mode 
    then, you want to change QDialog's size. So, as lykurg said, you replace dialog->size() by the QSize you want.

    now, what is the QSize you choose ?
    88
    88 is not a QSize

    Q.E.D.

  9. The following user says thank you to totem for this useful post:

    sousadaniel7 (6th May 2012)

  10. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Align QDialog

    Read the documentation about QSize (just click the link!). See which constructors are provided.

  11. The following user says thank you to Lykurg for this useful post:

    sousadaniel7 (6th May 2012)

Similar Threads

  1. QTabWidget align
    By AlexD in forum Qt Programming
    Replies: 6
    Last Post: 10th August 2012, 13:19
  2. QTextEdit align
    By mero in forum Qt Programming
    Replies: 5
    Last Post: 29th March 2011, 08:10
  3. Replies: 9
    Last Post: 25th March 2011, 21:22
  4. Question about align
    By Archa4 in forum Newbie
    Replies: 4
    Last Post: 14th March 2011, 08:36
  5. QDialog.exec() exiting without calling QDialog::accept()
    By doggrant in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2011, 11:35

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.