This might be the problem, you are trying to put a QMainWindow inside QMainWindow.Originally Posted by natron
This might be the problem, you are trying to put a QMainWindow inside QMainWindow.Originally Posted by natron
Good point.
I changed the parent class to QWidget, but like my story goes, it still doesn't work.
Since this is no longer a QMainWindow subclass, the setCentralWidget is no longer available. With or without the original layout code, my GUI isn't showing up. One noted difference though, the blank form that shows up with the layout code is small, slightly larger than the window decroations. Removing the layout code creates a huge window that feels close to a main window...I swear the solution must be near.
As a side, how do you experts start your Qt applications? This seems like a natural way to do it; it's similar to how I've done this type of thing in Gtk.
This time you try to put QMainWindow on QWidget.Originally Posted by natron
As you can see:
QMainWindow is always a top level window. You have to either change your .ui file or use a different approach.Qt Code:
{ d_func()->init(); }To copy to clipboard, switch view to plain text mode
I prefer to use uic instead of QUiLoader. If you store .ui files in resources it doesn't make much difference, except that the code generated by uic is smaller and runs faster.As a side, how do you experts start your Qt applications?
natron (20th July 2006)
Maybe you should create an instance of QMainWindow and then use setCentralWidget to set your widget as its main part? I mean something like:Originally Posted by natron
Qt Code:
int main(int argc, char **argv){ // ... QMainWindow mw; mw.setCentralWidget(createYourWidgetHere); //... mw.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
I don't exactly understand what you mean... How do we execute applications or how do we implement them?As a side, how do you experts start your Qt applications?
If the former then either from the command line, KDevelop or by clicking on an icon in Konqueror. I think all people do it in one of these ways...
If the latter, then I start by writing main.cpp with contents such as the one above, then implement my main ui, subclass it to create the main window class and then I check if it works fine. Afterwards I begin to implement the functionality.
And I don't use dynamically loaded forms![]()
natron (20th July 2006)
Hey, thanks you two for your help. I got it working so far.
I realized my blunder - I basically had the right code, just in the wrong place.
My main now loads the .ui file, followed by
Qt Code:
MainForm mfMain; mfMain.setCentralWidget(formWidget);To copy to clipboard, switch view to plain text mode
where the ctor for MainForm goes like so
Qt Code:
{ //... }To copy to clipboard, switch view to plain text mode
This makes a lot of sense too; it works like wysota's post above.
Any idea why Gtk's (using Glade) method of interface design explicitly promotes dynamic interface loading, while in Qt land the paradigm focuses on the static method? I can see advantages and restrictions in both, but neither seems clearly better.
<flame mode>Originally Posted by natron
Maybe because Qt is better?
</flame mode>
Qt is object oriented and focuses on using classes, also for things like the GUI, whereas Gtk is not object oriented and doesn't care about classes, so it doesn't matter where it creates its bunch of variables responsible for controlling the user interface. Of course that's my personal opinion![]()
Bookmarks