Results 1 to 4 of 4

Thread: setTabStopWidth doesn't work

  1. #1
    Join Date
    Mar 2007
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Question setTabStopWidth doesn't work

    I have my own subclass of QTextEdit (called Editor) for which I want to allow the user to set the tab width (ideally in number of spaces, but it looks like pixels is the only option). Anyway, using the setTabStopWidth member function doesn't do anything. I tried explicitly setting it to 200 pixels right after I declare it but, that doesn't seem to do anything. I didn't overload that function.

    Qt Code:
    1. class Editor : public QTextEdit {
    2. Q_OBJECT
    3. public :
    4. Editor( QWidget* parent = 0 );
    5. ~Editor();
    6. ...
    7. }
    8.  
    9. ...
    10.  
    11. mCommandEdit = new Editor;
    12. mCommandEdit->setTabChangesFocus(false);
    13. mCommandEdit->setTabStopWidth ( 200 );
    To copy to clipboard, switch view to plain text mode 

    I can post more complete code if necessary, but I just want to find out if this should work like I am thinking.

    Thanks.

  2. #2
    Join Date
    Mar 2006
    Posts
    48
    Thanks
    5
    Thanked 4 Times in 3 Posts

    Default Re: setTabStopWidth doesn't work

    Qt Code:
    1. setTabStopWidth( fontMetrics().width( " " ) * spacesCount );
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2007
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Question Re: setTabStopWidth doesn't work

    Quote Originally Posted by evgenM View Post
    Qt Code:
    1. setTabStopWidth( fontMetrics().width( " " ) * spacesCount );
    To copy to clipboard, switch view to plain text mode 
    Thanks for the tip on how to do it by spaces.

    However, this still doesn't solve the problem that setTabStopWidth doesn't do anything. The tabs are always the same! Any ideas?

  4. #4
    Join Date
    Mar 2006
    Posts
    48
    Thanks
    5
    Thanked 4 Times in 3 Posts

    Default Re: setTabStopWidth doesn't work

    how (and when) do u add text?

    try simple example
    in QTextEdit's constructor write only
    Qt Code:
    1. setTabStopWidth(..);
    2. setPlainText("text\ttext");
    To copy to clipboard, switch view to plain text mode 

    it work?

Similar Threads

  1. QActions don't work with menubar hidden
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 01:04
  2. Change work area OS
    By pakulo in forum Qt Programming
    Replies: 15
    Last Post: 15th May 2007, 07:20
  3. how to make QHttp work with this URL
    By ber_44 in forum Qt Programming
    Replies: 11
    Last Post: 23rd April 2007, 09:20
  4. QTextEdit Justify align making work
    By dec0ding in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2006, 12:02

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.