Results 1 to 7 of 7

Thread: QListView item with border 0 still visible

  1. #1
    Join Date
    Jul 2010
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default QListView item with border 0 still visible

    So what am I trying to do?
    I have QListView that loads string list and shows it on the screen. Following is extract from the code:

    Qt Code:
    1. list << "AAA" << "CCC" << "BBB";
    2. ui->listView->setModel( new QStringListModel(list) );
    To copy to clipboard, switch view to plain text mode 

    I'm using stylesheets to modify its appearance. In my case I just want color of text to change when item is selected. Following is stylesheet that I am using:

    QListView::item
    {
    color: black;
    background-color: transparent;
    border: 0px;
    }
    QListView::item:selected
    {
    color: red;
    background-color: transparent;
    border: 0px;
    }

    It works perfect in Qt Simulator (Windows).Behavior is as expected: color changes from black to red, both background colors are transparent, and there is no border.

    Now, the problem appears when I test it on Symbian Device (I'm testing on N97 mini). While color changes from black to red and background color remains transparent, border for some reason still appears. It is of white (whitish) color and it seems like 1 pixel wide.
    If I do add border (1px solid red), border appears around it. What do I need to do to remove this "white" border around QListView item?

    Thanks

  2. #2
    Join Date
    Apr 2010
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded

    Default Re: QListView item with border 0 still visible

    you should use the property:setFrame::NoFrame ,I think so.

  3. #3
    Join Date
    Jul 2010
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: QListView item with border 0 still visible

    You probably meant
    QListView::setFrameStyle( QFrame::NoFrame );

    I tried that and it doesn't work. I also tried setSelectionRectVisible( false ) but behaviour is still the same.

    Any other ideas? I'm starting to suspect that this border/frame cannot be hidden at all!

  4. #4
    Join Date
    Aug 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QListView item with border 0 still visible

    I got rid of listwidget-borders by calling setContentsMargins on the layout holding the widget.

    Qt Code:
    1. layout->setContentsMargins(0,0,0,0);
    To copy to clipboard, switch view to plain text mode 

    Hope it helps
    /anton

  5. #5
    Join Date
    Jul 2010
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: QListView item with border 0 still visible

    No success, I tried:
    Qt Code:
    1. ui->listView->setContentsMargins( 0,0,0,0 );
    To copy to clipboard, switch view to plain text mode 

    Should I have used setContentsMargins on some other item?
    White rectangle still appears around each item when it is selected. Any other suggestions?

  6. #6
    Join Date
    Sep 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: QListView item with border 0 still visible

    Hi,

    I have same problem. It looks like border is around only text of item. Icon is rendered outside of border. I've tried to play with QListView::text in Qt Style Sheet, but it looks like any changes in QListView::text have no any effects. Can someone help me with it?

    Thank you.

  7. #7
    Join Date
    Jan 2010
    Posts
    18
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QListView item with border 0 still visible

    Several things to try:

    border:none;

    I've had occasions where I'm using stylesheets, but I had to localize some of the settings in the .cpp files. For example:

    ui->setupUi(this);

    this->setStyleSheet("\
    QLabel {\
    color: white;\
    background-color: black;\
    font: bold normal 8pt;\
    border-style: solid;\
    border-width: 1px;\
    border-radius: 8px;\
    border-color: black;\
    padding: 3px;\
    }\
    ");

    leftLayout = new QGridLayout();

    And sometimes I've had to localize style sheet settings to particular objects:

    QLabel * TmpLabel= new QLabel();
    TmpLabel->setStyleSheet(put your settings here);

    Hope this helps.

Similar Threads

  1. QListview set selected item
    By Freeman551 in forum Qt Programming
    Replies: 1
    Last Post: 25th December 2009, 01:17
  2. Add new item to a QListView
    By graciano in forum Newbie
    Replies: 2
    Last Post: 18th August 2009, 19:49
  3. QListView item alignment
    By innerhippy in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2008, 10:32
  4. how to move item up and down in QListView
    By zhanglr in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2008, 15:39
  5. hidden QListView column suddenly visible
    By edb in forum Qt Programming
    Replies: 10
    Last Post: 27th January 2006, 09:00

Tags for this Thread

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.