eric
8th January 2008, 17:22
Hello!
I want the size of my main window to change as the program runs.
This is my main function
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
MyWidget window;
int x = 100; int y =100;
QRect screen = qApp->desktop()->screenGeometry();
window.setGeometry(5,20,screen.width()-x,screen.height()-y);
window.show();
return application.exec();
}
This above positions my window where I want it. But as the program runs the x and y variables will change and I'd like to resize window by doing
window.setGeometry(5,20,screen.width()-x,screen.height()-y);
from other functions. I cannot do this since "window" is not reconized by other functions.
I don't think I can put this implementation
MyWidget window; in my *.h file to make it public since that wouldn't work.
Does anyone have suggestions how to make this automatic window resizing work so that it could be done from functions other than "main". Maybe use updateGeometry() somehow?
I want the size of my main window to change as the program runs.
This is my main function
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
MyWidget window;
int x = 100; int y =100;
QRect screen = qApp->desktop()->screenGeometry();
window.setGeometry(5,20,screen.width()-x,screen.height()-y);
window.show();
return application.exec();
}
This above positions my window where I want it. But as the program runs the x and y variables will change and I'd like to resize window by doing
window.setGeometry(5,20,screen.width()-x,screen.height()-y);
from other functions. I cannot do this since "window" is not reconized by other functions.
I don't think I can put this implementation
MyWidget window; in my *.h file to make it public since that wouldn't work.
Does anyone have suggestions how to make this automatic window resizing work so that it could be done from functions other than "main". Maybe use updateGeometry() somehow?