MainWindow::setCentralWidget(spectrograph);
MainWindow::setCentralWidget(spectrograph);
To copy to clipboard, switch view to plain text mode
This line is nonsense, anyway, unless it is in the constructor of your MainWindow, in which case the MainWindow:: scoping qualifier is superfluous. Just do this:
setCentralWidget(spectrograph);
setCentralWidget(spectrograph);
To copy to clipboard, switch view to plain text mode
I am not sure what you are doing in your code, because if I create a QMainWindow-derived class as my main widget and set *anything* as the central widget (with or without a layout, toolbars, dock widgets, or any other code), the main window will automatically resize it to fill the entire space.
So if what you want is a main window where you fill it at run time, delete the ui file, remove the Ui::MainWindow member variable (or inheritance, however you do it), remove the setupUi(), and simply make a new instance of your widget in the MainWindow constructor and set it as the central widget. No layout or ui form needed:
MainWindow
::MainWindow( QWidget * parent
){
Spectrograph * spectrograph = new Spectrograph;
// do whatever you need to do to set up the spectrograph instance and its connections
setCentralWidget( spectrograph );
}
MainWindow::MainWindow( QWidget * parent )
: QMainWindow( parent )
{
Spectrograph * spectrograph = new Spectrograph;
// do whatever you need to do to set up the spectrograph instance and its connections
setCentralWidget( spectrograph );
}
To copy to clipboard, switch view to plain text mode
and that's it. If you want to add menus, toolbars, and whatever, you can use the designer for that (or implement them directly in the constructor code), but don't specify anything as the central widget in the designer. If you do use the designer for that, then you'll need to keep all the Ui:: related stuff.
I tend to create my main windows in code rather than use the designer. I don't like looking in two or three places to figure out what my menu items, actions, and connections do. For dialogs and forms, I use the designer simply because it is easier to get the layout right.
Bookmarks