read the position of an another window from a new window
Hi,
I have a program in QT 4.3. In that I have a main window and a child window. In that childwindow I have a command button. When I click on that command button, I need to load an another screen. My probs is that, I need to show the new window at the bottom of the cirst fhild window. For that I need to know the current 'x' and 'y' position of the first child window. How can read that position from the new window.
Please help me....
Re: read the position of an another window from a new window
QWidget::rect() contains the rectangle occupied by each widget. For top-level windows these are in global coordinates.
Re: read the position of an another window from a new window
Hi,
With the help of this, QWidget::rect() How can i read the position of another window?
Can you please give an example for this?
Re: read the position of an another window from a new window
You want to align the new windows with the bottom of the childwindow that created it. So when you create the new Window, you read the rect() value from the firstChildWindow that you probably have a pointer to somewhere in your application and then move to the new window to the bottom of the child window with move or setGeometry().
Code:
//slot creating the new window
void createWindow() {
window->move(frameGeometry().bottomLeft());
window->raise();
window->show();
}
here is a simple implementation:
Code:
#include <QtGui>
{
Q_OBJECT
public:
{
connect(newButton, SIGNAL(clicked()), this, SLOT(createWindow()));
layout->addWidget(newButton);
}
private slots:
void createWindow() {
window->move(frameGeometry().bottomLeft());
window->raise();
window->show();
}
};
int main(int argc, char* argv[])
{
TestDlg dialog;
dialog.show();
return app.exec();
}
#include "main.moc"