Results 1 to 4 of 4

Thread: setTabStopWidth not working correctly?

  1. #1
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default setTabStopWidth not working correctly?

    Hello everyone, im making an IDE for a programming language called PAWN. I have syntax highlighting down, but one problem im having is indentation. For starters tab doesnt indent correctly, so i tried using setTabStopWidth to fix this. I was worried about how it would scale when users change fonts and font sizes though, so i looked for a way to do it in a much cleaner manner than trial and error for a single font/font size.

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

    This is what i eventually found. This was working fine for the default font, but it really doesnt seem to like when i use other custom fonts like Courier New. It should be indenting four spaces or so, but it only indenting about 2 spaces. Im not sure if i need to DO something when i set a QTextEdit's font so setTabStopWidth will work, or if the function simply doesnt work correctly. Either way, indentation is messed up with different fonts and that needs to be fixed.



    My second part of the question is, how would i go about making an auto-indent like feature? Im sure its pretty simple, but i've obviously over looked it. Im not asking for code hand outs, just how i would resolve my two questions.

  2. #2
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setTabStopWidth not working correctly?

    This is me bumping my topic because i am in need of assistance, and apparently need 10 characters to submit a message. Rather than typing "bump" and be done with it im going to keep typing, simply because i am bored enough to do so. No one has so far been able to assist me on any IRC channel or forum and im not sure why. This seems relatively straight forward, and i know there are skilled programmers out there. Perhaps there is a conspiracy going on!? Or perhaps im seriously sleep deprived and am making mountians out of mole hills, either way one thing is for certain.... mountain dew time.

    I hope you liked my story, even though there was a severe lack of dragons and pink assault flamignos.

  3. #3
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: setTabStopWidth not working correctly?

    Just take a look like aut-indent feature works in other IDEs and try to mimic that.

    For example, when user hits enter previous line is investigated. If { is found at the end, indent increases, if ; is found it remains the same, if } is found it decreases.
    You don't need to keep track of anything as you can figure out previous level by counting the spaces at the beggining of a line.

    I'm not sure about your first questions but I liked your story

  4. #4
    Join Date
    Oct 2011
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setTabStopWidth not working correctly?

    I meant more like HOW i would indent it lol. I cant even have the USER indent the damn code correctly, so its just really frustrating.

Similar Threads

  1. Replies: 0
    Last Post: 3rd March 2011, 17:01
  2. Replies: 1
    Last Post: 19th March 2009, 13:40
  3. Drop not working correctly
    By rippa in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2008, 15:13
  4. renderText is not working correctly
    By validator in forum Qt Programming
    Replies: 3
    Last Post: 27th May 2008, 16:55
  5. setTabStopWidth doesn't work
    By discostu in forum Qt Programming
    Replies: 3
    Last Post: 19th November 2007, 08:29

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.