# Qt. Dialog and main windows location

**URL:** <https://www.ruby-forum.com/t/qt-dialog-and-main-windows-location/177389>\
**Category:** Ruby\
**Created:** [October 16, 2009, 4:51am UTC](https://www.ruby-forum.com/t/qt-dialog-and-main-windows-location/177389 "2009-10-16T04:51:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![born\_in\_USSR](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/2bfe46/32.png) [@born\_in\_USSR](https://www.ruby-forum.com/u/born_in_USSR)\
**Post date:** [October 16, 2009, 4:51am UTC](https://www.ruby-forum.com/t/qt-dialog-and-main-windows-location/177389/1 "2009-10-16T04:51:58Z")

</div>

I’m new in Qt. I create main and dialog windows in Qt4 Designer. I want  
to place dialog window in the middle of main window, and place main  
window in the center of screen. Is it possible?

> > code:  
> > require ‘Qt4’  
> > require ‘mainwindow.rb’  
> > require ‘logindialog.rb’

class MW \< Qt::MainWindow  
slots ‘setfocus()’  
def initialize parent=nil  
super  
@ui = Ui\_MW.new  
@ui.setupUi self  
…  
end  
end

class LoginDL \< Qt::Dialog  
slots ‘enter\_click()’  
def initialize parent=nil  
super  
@ui = Ui\_LoginDL.new  
@ui.setupUi self  
…  
end  
…  
end

if $0 == **FILE**  
app = Qt::Application.new(ARGV)  
$mainw = MW.new  
$mainw.show

```
loginw=LoginDL.new
loginw.show
app.exec

```

end
