Results 1 to 2 of 2

Thread: QMainWindow layout questions maybe

  1. #1
    Join Date
    Sep 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Cool QMainWindow layout questions maybe

    strange error RtlWerpReportException failed with status code :-1073741823. Will try to launch the process directly

    maincode:

    Qt Code:
    1. #include <QtGui>
    2. #include "mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent)
    5. :QMainWindow(parent)
    6. {
    7. QPushButton *previousPushButton = new QPushButton("&Previous");
    8. QPushButton *okPushButton = new QPushButton("&Ok");
    9. QHBoxLayout *buttonLayout = new QHBoxLayout;
    10. buttonLayout->addWidget(previousPushButton);
    11. buttonLayout->addWidget(okPushButton);
    12.  
    13. //
    14. QLabel *nameLabel = new QLabel("&Name");
    15. QLineEdit *nameLineEdit = new QLineEdit;
    16. nameLabel->setBuddy(nameLabel);
    17. QHBoxLayout *nameLayout = new QHBoxLayout;
    18. nameLayout->addWidget(nameLabel);
    19. nameLayout->addWidget(nameLineEdit);
    20.  
    21. QLabel *workPlaceLabel = new QLabel("&WorkPlace");
    22. QLineEdit *workPlaceLineEdit[3];
    23. for (int i = 0; i < 3; i++)
    24. workPlaceLineEdit[i] = new QLineEdit;
    25. workPlaceLabel->setBuddy(workPlaceLineEdit[0]);
    26. QGridLayout *workPlaceLayout = new QGridLayout;
    27. workPlaceLayout->addWidget(workPlaceLabel, 0, 0);
    28.  
    29. for (int i = 0; i < 3; i++)
    30. workPlaceLayout->addWidget(workPlaceLineEdit[i], i, 1);
    31.  
    32. //
    33. QVBoxLayout *rightLayout = new QVBoxLayout;
    34. rightLayout->addLayout(nameLayout);
    35. rightLayout->addLayout(workPlaceLayout);
    36. rightLayout->addLayout(buttonLayout);
    37.  
    38. QTextBrowser *browser = new QTextBrowser();
    39. QVBoxLayout *leftLayout = new QVBoxLayout;
    40. leftLayout->addWidget(browser);
    41.  
    42. QHBoxLayout *mainLayout = new QHBoxLayout;
    43. mainLayout->addLayout(leftLayout);
    44. mainLayout->addLayout(rightLayout);
    45.  
    46. centralWidget()->setLayout(mainLayout);
    47. }
    To copy to clipboard, switch view to plain text mode 


    i don't know why this doesn't work
    Last edited by wysota; 21st July 2010 at 19:11. Reason: missing [code] tags

  2. #2
    Join Date
    Jun 2010
    Location
    Salatiga, Indonesia
    Posts
    160
    Thanks
    11
    Thanked 32 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    1

    Default Re: QMainWindow layout questions maybe

    I don't see you call setCentralWidget(QWidget *) in your MainWindow constructor. You need to look at QMainWindow::centralWidget() explanation.

Similar Threads

  1. QToolBar Layout(when part of QMainWindow)
    By iridium in forum Qt Programming
    Replies: 3
    Last Post: 18th April 2013, 13:19
  2. Adding a Layout to QMainWindow
    By Chiggins in forum Qt Programming
    Replies: 2
    Last Post: 7th June 2010, 06:25
  3. Problems with QMainWindow and layout
    By franco.amato in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 22:49
  4. Layout, widgets and resize questions
    By Carlsberg in forum Qt Programming
    Replies: 2
    Last Post: 26th June 2009, 12:49
  5. Maximumsize by layout QMainWindow
    By captiva in forum Qt Programming
    Replies: 7
    Last Post: 24th February 2009, 19:41

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.