Qt World Summit: Register Today!

Mainwindow layout change

  • Actually i face a problem while going form one Mainwindow to another Mainwindow..
    suppose i have mainwindow name Mainwindow1 and another mainwindow name Mainwindow2...now on the pushbutton of Mainwindow1 when i want to go to Mainwindow2 then it works but the layout of the mainwindow changes..its size decreses..

    the code i have wrritten in pushbutton of Mainwindow is..

    @void MainWindow1:n_Clicked_pushButton()
    MainWindow2 *m=new Mainwindow();
    but when i perform same task by using diaglog its works fine..so whats the problem..if anyone please suggest..

    with regards

  • I can't say i understood your problem, but in the second main-window do you have a "container" QWidget as a parent of the rest of the Widgets (and layouts) and add that in the main-window using setCentralWidget?

    And a second issue is that code you wrote will leak - the pointer m will get out of scope when the function ends and you can't delete the allocated MainWindow2 object (and you don't pass a parent that will delete that for you)

    Also you have a typo: MainWindow 2 *m=new Mainwindow();

  • There are more typos, the code should be:

    void MainWindow1:n_Clicked_pushButton()
    MainWindow2 *m=new MainWindow2();

  • thanks Gerolf..
    But i had try that also...result is same..is there any way to resolve this

  • thanks Zlatomir

    its working..by using setCentralWidget.....

    with regards

Log in to reply