PDA

View Full Version : how to determine geometry of a QFrame



impeteperry
5th October 2007, 15:27
Hi
I have a QFrame *frame A and I want to place a QFrame *helpFrame in it
emit displayHelpFunction( frameA, &helpFlag);
frameA->show();
and the code in the sub-frame is
void HelpFunction::slotDisplayHelpFunction( QFrame *sourceFrame, bool *flag )
{
if ( *flag == false)
{
helpFrame = new QFrame( sourceFrame );
helpFrame->setFrameShape( QFrame::StyledPanel );
helpFrame->setGeometry( 10, 10, 200, 400 );
teHelpBox= new QTextEdit( helpFrame );
teHelpBox->setGeometry(10,10, 180, 380);
teHelpBox->setPlainText( "Now is the time" );
helpFrame->show();
*flag = true;
}
else if ( *flag == true )
{
*flag = false;
helpFrame->hide();
}
}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.

marcel
5th October 2007, 15:29
See QWidget::geometry();
But it is recommended to use layouts instead placing widgets manually.

impeteperry
10th October 2007, 18:45
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

ToddAtWSU
10th October 2007, 19:07
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.