Results 1 to 8 of 8

Thread: QMainWindow

  1. #1
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QMainWindow

    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
    Franco Amato

  2. #2
    Join Date
    Jan 2006
    Location
    Shanghai, China
    Posts
    52
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow

    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.
    1. Users don't have the manual, and if they did, they wouldn't read it.
    2. In fact, users can't read anything, and if they could, they wouldn't want to.

  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow

    Quote Originally Posted by bood View Post
    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
    Last edited by franco.amato; 17th December 2009 at 00:33.
    Franco Amato

  4. #4
    Join Date
    Jan 2006
    Location
    Shanghai, China
    Posts
    52
    Thanks
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow

    Of course QDialog could have menu and status bar etc, you can always add them yourself.

    Qt Code:
    1. QMenuBar menuBar = new QMenuBar(this);
    2. menuBar->addAction("File");
    3. menuBar->addAction("Tools");
    To copy to clipboard, switch view to plain text mode 
    1. Users don't have the manual, and if they did, they wouldn't read it.
    2. In fact, users can't read anything, and if they could, they wouldn't want to.

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QMainWindow

    Quote Originally Posted by bood View Post
    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.

  6. #6
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow

    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, QWidgetand 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.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  7. #7
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow

    Quote Originally Posted by Lykurg View Post
    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

  8. #8
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QMainWindow

    Quote Originally Posted by faldżip View Post
    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, QWidgetand 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
    Franco Amato

Similar Threads

  1. QMainWindow with QMainWindow
    By baray98 in forum Qt Programming
    Replies: 3
    Last Post: 12th April 2011, 07:07
  2. Maximumsize by layout QMainWindow
    By captiva in forum Qt Programming
    Replies: 7
    Last Post: 24th February 2009, 19:41
  3. QMainWindow setCentralWidget from ui widget, Qt4
    By alan in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2008, 13:00
  4. QMainWindow child of a QDialog
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 16th January 2008, 07:16
  5. Replies: 18
    Last Post: 22nd February 2006, 20:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.