Results 1 to 4 of 4

Thread: how to determine geometry of a QFrame

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default how to determine geometry of a QFrame

    Hi
    I have a QFrame *frame A and I want to place a QFrame *helpFrame in it
    Qt Code:
    1. emit displayHelpFunction( frameA, &helpFlag);
    2. frameA->show();
    To copy to clipboard, switch view to plain text mode 
    and the code in the sub-frame is
    Qt Code:
    1. void HelpFunction::slotDisplayHelpFunction( QFrame *sourceFrame, bool *flag )
    2. {
    3. if ( *flag == false)
    4. {
    5. helpFrame = new QFrame( sourceFrame );
    6. helpFrame->setFrameShape( QFrame::StyledPanel );
    7. helpFrame->setGeometry( 10, 10, 200, 400 );
    8. teHelpBox= new QTextEdit( helpFrame );
    9. teHelpBox->setGeometry(10,10, 180, 380);
    10. teHelpBox->setPlainText( "Now is the time" );
    11. helpFrame->show();
    12. *flag = true;
    13. }
    14. else if ( *flag == true )
    15. {
    16. *flag = false;
    17. helpFrame->hide();
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 
    and it works fine, with the "helpFrame" in the upper left corner of "frameA", but I want line 7. in terms of the "width" and "height" of frameA.
    I don't want to use "spacers" or a "paint" event to get these dimensions if I can help it.

    help would be most appreciated.

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

    Default Re: how to determine geometry of a QFrame

    See QWidget::geometry();
    But it is recommended to use layouts instead placing widgets manually.

  3. The following user says thank you to marcel for this useful post:

    impeteperry (8th October 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: how to determine geometry of a QFrame

    Quote Originally Posted by marcel View Post
    See QWidget::geometry();
    But it is recommended to use layouts instead placing widgets manually.
    Thanks, I have given up and gone back to designer.
    Going through the discussions, as best I could, I did not find a single reference to "frame.width()" or other such simple, direct, usuable functions. Only in the primary documentations where they are listed.

    Thanks anyway
    pete

  5. #4
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to determine geometry of a QFrame

    Quote Originally Posted by marcel View Post
    But it is recommended to use layouts instead placing widgets manually.
    I think what Marcel was saying is if you would create a layout and make the layout to lie in the main frame. Then add your secondary frame into the layout and work with the layout to manipulate the position it lies in.

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.