Results 1 to 5 of 5

Thread: QTextEdit is too small in QMainWindow

  1. #1
    Join Date
    Aug 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QTextEdit is too small in QMainWindow

    I believe the picture speaks for itself. It's a very simple program with a major issue!

    Moreover, if I try to add a button and use the QVBoxLayout the button is added over the QTextEdit in the same corner.

    LE: Here's the image http://img713.imageshack.us/img713/6827/qtextbox.png
    Attached Images Attached Images

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QTextEdit is too small in QMainWindow

    When you use QMainWindow, you can't use layouts directly. That is because the QMainWindow already has a layout (In the output of your Qt Creator you get a message about this issue)

    To solve this you can create a QWidget that you use like a container for your layout (with all the other widgets) and use the setCentralWidget() (pass a pointer to the "container" QWidget)

  3. The following user says thank you to Zlatomir for this useful post:

    zoz (9th September 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTextEdit is too small in QMainWindow

    You need to add your widgets to a layout.

  5. #4
    Join Date
    Aug 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextEdit is too small in QMainWindow

    Quote Originally Posted by Zlatomir View Post
    When you use QMainWindow, you can't use layouts directly. That is because the QMainWindow already has a layout (In the output of your Qt Creator you get a message about this issue)

    To solve this you can create a QWidget that you use like a container for your layout (with all the other widgets) and use the setCentralWidget() (pass a pointer to the "container" QWidget)
    Damn, I always forget that, thanks! So I tried to make two additional widgets, but it seems that the lower one is not visible. Here's the code: http://yfrog.com/nfwidgetp

    Moreover, ButtonWidget's parent is MainWidget. MainWidget's parent is that default QMainWindow. Is this "parenting" OK?

  6. #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: QTextEdit is too small in QMainWindow

    first attach your images here on the forum, not on 3rd party sites, second please also post your code that it is not only viewable on your image.

    Solution: create your ButtonsWidget on the heap, not on the stack. Because right now it gets deleted after the scope reaches it end. So before it is being displayed it has already been deleted. (Basic C++ stuff.)

Similar Threads

  1. QMainWindow as a child of QMainWindow
    By Elder Orb in forum Qt Programming
    Replies: 8
    Last Post: 12th February 2011, 21:31
  2. Small problem
    By NewLegend in forum Qt Programming
    Replies: 1
    Last Post: 23rd July 2010, 21:52
  3. Small Libraries
    By porfirio in forum Installation and Deployment
    Replies: 7
    Last Post: 13th August 2009, 10:16
  4. Replies: 1
    Last Post: 16th February 2007, 07:22

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.