Results 1 to 6 of 6

Thread: QListWidget + setWindowFlags = bad scrollbar

  1. #1
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QListWidget + setWindowFlags = bad scrollbar

    I create a modal gui just to show a list with a QListWidget.
    This is the class:

    Qt Code:
    1. class CShowRolesModalGui : public QDialog
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. CShowRolesModalGui(const QStringList& items, QWidget* parent);
    7.  
    8. private slots:
    9. void Close () { done(0); }
    10. };
    To copy to clipboard, switch view to plain text mode 

    and this is the code:
    Qt Code:
    1. CShowRolesModalGui::CShowRolesModalGui(const QStringList& items, QWidget* parent) : QDialog(parent)
    2. {
    3. setGeometry(QRect(QPoint(205, 430), QSize(400, 300)));
    4. setFixedSize(400, 300);
    5. setStyleSheet(ROLES_WIDGET_STYLE);
    6. setWindowFlags(Qt::FramelessWindowHint);
    7.  
    8. QListWidget* listView = new QListWidget(this);
    9. listView->setGeometry(2, 2, 396, 260);
    10. listView->setStyleSheet(LIST_SHOW_ROLE_STYLE);
    11. listView->addItems(items);
    12.  
    13. QPushButton* btn = new QPushButton(tr("Ok"), this);
    14. btn->setGeometry(175, 265, 50, 30);
    15. btn->setStyleSheet(FREQ_MODAL_BTN_STYLE);
    16. connect(btn, SIGNAL(clicked()), this, SLOT(Close()));
    17. }
    To copy to clipboard, switch view to plain text mode 

    If I call the function setWindowFlags (and I have to call it as I don't want a gui with a border), the QListWidget's scrollbar is visible but doesn't work with the mouse buttons, only with the wheel and the keyboard.

    How can I solve the problem ? I really need a GUI without a border.
    Thanks.

    PS: I doesn't work also with:
    setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
    setWindowFlags(Qt::FramelessWindowHint);
    setWindowFlags(Qt::CustomizeWindowHint);
    and so on ...

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QListWidget + setWindowFlags = bad scrollbar

    can you attach minimal compilable example which reproduces the problem?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QListWidget + setWindowFlags = bad scrollbar

    I'd start by using layouts in your program. Next I'd try if removing the style sheet fixes the problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Aug 2009
    Posts
    92
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default

    Sorry I was in a meeting ...

    Ok, I've just tried to remove the stylesheet and it works.
    The stylesheet was like this:

    Qt Code:
    1. #define ROLES_WIDGET_STYLE \
    2. "color: black;" \
    3. "font: bold;" \
    4. "border: 2px solid black; " \
    5. "border-radius: 5px; " \
    6. "padding: 0px; " \
    7. "background-color: rgb(200, 200, 200);"
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by wysota View Post
    I'd start by using layouts in your program. Next I'd try if removing the style sheet fixes the problem.
    Why layouts ? it's only a stupid sub gui that shows only a list.

    Ok, found.
    If only one of these style is set, the scrollbar doesn't work with the mouse.

    border: 2px solid black;
    border-radius: 5px;
    background-color: rgb(200, 200, 200);


    Can understand the border, but the background-color ???
    Last edited by wysota; 9th December 2009 at 11:05.

  5. #5
    Join Date
    Jun 2008
    Location
    Saint-Petersburg
    Posts
    50
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QListWidget + setWindowFlags = bad scrollbar

    Quote Originally Posted by trallallero View Post

    background-color: rgb(200, 200, 200);
    Should you try this string:

    Qt Code:
    1. background-color: #C8C8C8;
    To copy to clipboard, switch view to plain text mode 
    ?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QListWidget + setWindowFlags = bad scrollbar

    You should probably style the scrollbar's groove as well.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QListWidget problem [solved]
    By satoshi in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2009, 18:58
  2. Treeview scrollbar not updating when inserting rows
    By Khal Drogo in forum Qt Programming
    Replies: 11
    Last Post: 29th November 2007, 13:13
  3. GraphicsView/GraphicsScene: scrollbar policy Qt::ScrollBarAsNeeded
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2007, 13:15
  4. about scrollbar style
    By qtopiahooo in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 13:34
  5. Replies: 13
    Last Post: 15th December 2006, 11:52

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.