Results 1 to 4 of 4

Thread: Q3listbox center items

  1. #1
    Join Date
    Feb 2006
    Posts
    60
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Q3listbox center items

    Hi,
    i am using Qt4.1. I have a Q3ListBox, and i want to align the items in the box, to the right or to the center.

    Please reply me.

    regards,
    sree

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Q3listbox center items

    Inherit Q3ListBoxItem and override:
    void Q3ListBoxItem:aint ( QPainter * p ) [pure virtual protected]

    In paint(), you can draw aligned text with:
    void QPainter::drawText ( const QRectF & rectangle, const QString & text, const QTextOption & option = QTextOption() )

    by supplying a QTextOption whose text aligment has been set to your like.

  3. #3
    Join Date
    Feb 2006
    Posts
    60
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Q3listbox center items

    Thanks a lot it works fine

  4. #4
    Join Date
    Feb 2006
    Posts
    60
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Q3listbox center items

    The same can be done also with
    void QPainter::drawText ( const QRect & r, int flags, const QString & str, QRect * br = 0 )
    where the flags can be used for alignment

    sree

Similar Threads

  1. Some menubar items can not be clicked
    By richardander in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2009, 00:26
  2. How to align list items to the center?
    By zgulser in forum Qt Tools
    Replies: 4
    Last Post: 9th February 2009, 09:52
  3. Light items for the graphicsView
    By maverick_pol in forum Qt Programming
    Replies: 12
    Last Post: 1st November 2007, 18:51
  4. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 12:20

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.