PDA

View Full Version : QMainWindow



franco.amato
16th December 2009, 23:24
Hi the Qt doc says that a QMainWindow must have a central widget.
In my application I derived from QMainWindow but effectively I don't have a real central widget and docket widgets as in the Qt examples.
I have 2 waveform displays ( that needs a scroll bar ) and some additional controls.
So how can I set my QMainWindow?

Best Regards

bood
17th December 2009, 00:17
You can put everything in a general QWidget and set the QWidget as the central widget.

Or, you can just derive your main window from QDialog instead if you don't have to use MainWindow, so you don't have to worry about this at all.

franco.amato
17th December 2009, 01:07
You can put everything in a general QWidget and set the QWidget as the central widget.

Or, you can just derive your main window from QDialog instead if you don't have to use MainWindow, so you don't have to worry about this at all.

But the QDialog don't offer menu, status bar, etc.
And I don't know how to layout it.
In the QMainWindow I would place:
1 WaveWidget (wave1)
1 WaveWidget (wave2)
others controls (buttons etc)
all vertically.
Every WaveWidget must have its scroll bar.

Is really difficult to understand this concept for me, and I really don't know why Qt decided
to adopt this concept of central widget.
I think is the only library that did it.

Best

bood
18th December 2009, 04:02
Of course QDialog could have menu and status bar etc, you can always add them yourself.



QMenuBar menuBar = new QMenuBar(this);
menuBar->addAction("File");
menuBar->addAction("Tools");

Lykurg
18th December 2009, 08:46
Of course QDialog could have menu and status bar etc, you can always add them yourself.
But then you can't float and move the menu bar out of the box.

faldzip
18th December 2009, 08:54
You can just put everything in the central widget. I don't see the problem. If your application have one main window then it is your choice if it is QMainWindow, QDialog, QWidget and so on. With this three you always have the main widget area: in QWidget and QDialog this are themselfs and in QMainWindow it is the central widget. Just place everything in proper layouts and it should work for those classes. QMainWindow just offers more then QWidget or QDialog, because has dock areas for example.

franco.amato
18th December 2009, 18:41
But then you can't float and move the menu bar out of the box.

Hi, I don't want to float and move the menu bar.
I would it fixed at its position.

franco.amato
18th December 2009, 18:45
You can just put everything in the central widget. I don't see the problem. If your application have one main window then it is your choice if it is QMainWindow, QDialog, QWidget and so on. With this three you always have the main widget area: in QWidget and QDialog this are themselfs and in QMainWindow it is the central widget. Just place everything in proper layouts and it should work for those classes. QMainWindow just offers more then QWidget or QDialog, because has dock areas for example.

So if I would have
Menu bar,
tool bar,
status bar,
and my custom widgets that I don't want be float, but fixed I can use QDialog approach?
I still have problem in layout them