Results 1 to 3 of 3

Thread: Code for Horizontal spacer

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

    Default Code for Horizontal spacer

    I have a QMainWindow with the central widget set as a QTextEdit. I want to add in a horizontal spacer on each side so the screen will look more like a microsoft word doc or something where theres the white page in the center and then a border type thing on the sides.

    Is there a way to do this?

    thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Code for Horizontal spacer

    To place unused space left or right of the text edit put the QTextEdit into a QHBoxLayout and use one of the functions addSpacerItem() , addSpacing() or addStretch() to add spacing.

  3. #3
    Join Date
    Aug 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Code for Horizontal spacer

    alright awesome thanks! This might be a dumb question but this is opened from another window and when I try to use setLayout it tries to set it on the original window so I tried making a QMainWindow and setting the layout for that but it wont work, it says that QMainWindow already has a layout. Do you know how I can make a new window pop up and still use QHBoxLayout?


    Added after 1 37 minutes:


    nevermind.. I used a QWiget instead of QMainWindow and it worked.

    Thanks Chris
    Last edited by Gary7; 15th August 2012 at 04:52.

Similar Threads

  1. Replies: 1
    Last Post: 20th May 2011, 17:36
  2. Grid QTableView horizontal only
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 11th September 2009, 16:14
  3. QPainterPath horizontal flip
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 28th October 2007, 20:17
  4. Designer: Spacer doesn't do what I want...
    By jochen_r in forum Qt Tools
    Replies: 3
    Last Post: 19th January 2006, 05:23

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.