Results 1 to 6 of 6

Thread: Combobox style problem

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Combobox style problem

    Hi,

    I can't afford to set text or item alignment for the items in the combobox. Is there a way to do this?

    King Regards

  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: Combobox style problem

    Qt Code:
    1. for (int i = 0; i < comboBox->count(); ++i)
    2. comboBox->setItemData(i, Qt::AlignCenter, Qt::TextAlignmentRole);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Combobox style problem

    Hi,

    thanks jpn for your response but it doesn't change the aligment of the item when it is selected. But it worked when the drop down was pressed for the items to be selected.

    thanks in advance.

  4. #4
    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: Combobox style problem

    Qt Code:
    1. comboBox->setEditable(true); // force a line edit to be created
    2. comboBox->lineEdit()->setAlignment(Qt::AlignCenter);
    3. comboBox->lineEdit()->readOnly(true); // make it read-only if you want to
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. #5
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Combobox style problem

    thanks jpn. it's working with some minor troubles.

  6. #6
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Combobox style problem

    Hi,

    when I do this, Combobox strangely sets a frame around the lineedit. When I do setEditable(FALSE), after the alignment, alignment crashes.

Similar Threads

  1. Performace problem with style sheets
    By Cruz in forum Qt Programming
    Replies: 0
    Last Post: 7th February 2009, 14:20
  2. Problem in displaying the ComboBox list
    By raghvendramisra in forum Qt Tools
    Replies: 4
    Last Post: 28th February 2008, 14:25
  3. BIG Problem with Background-image using Style Sheets
    By PiXeL16 in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 23:10
  4. [Qt 4.3.1]A problem with combobox style
    By Tamara in forum Qt Programming
    Replies: 3
    Last Post: 19th September 2007, 11:49
  5. Problem with a combobox
    By Tindor in forum Qt Programming
    Replies: 2
    Last Post: 22nd November 2006, 20:18

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.