PDA

View Full Version : setTabStopWidth doesn't work



discostu
18th November 2007, 07:23
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.



class Editor : public QTextEdit {
Q_OBJECT
public :
Editor( QWidget* parent = 0 );
~Editor();
...
}

...

mCommandEdit = new Editor;
mCommandEdit->setTabChangesFocus(false);
mCommandEdit->setTabStopWidth ( 200 );


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

Thanks.

evgenM
18th November 2007, 09:06
setTabStopWidth( fontMetrics().width( " " ) * spacesCount );

discostu
18th November 2007, 17:49
setTabStopWidth( fontMetrics().width( " " ) * spacesCount );


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?

evgenM
19th November 2007, 08:29
how (and when) do u add text?

try simple example
in QTextEdit's constructor write only


setTabStopWidth(..);
setPlainText("text\ttext");


it work?