PDA

View Full Version : QListWidget + setWindowFlags = bad scrollbar



trallallero
9th December 2009, 09:21
I create a modal gui just to show a list with a QListWidget.
This is the class:


class CShowRolesModalGui : public QDialog
{
Q_OBJECT

public:
CShowRolesModalGui(const QStringList& items, QWidget* parent);

private slots:
void Close () { done(0); }
};

and this is the code:

CShowRolesModalGui::CShowRolesModalGui(const QStringList& items, QWidget* parent) : QDialog(parent)
{
setGeometry(QRect(QPoint(205, 430), QSize(400, 300)));
setFixedSize(400, 300);
setStyleSheet(ROLES_WIDGET_STYLE);
setWindowFlags(Qt::FramelessWindowHint);

QListWidget* listView = new QListWidget(this);
listView->setGeometry(2, 2, 396, 260);
listView->setStyleSheet(LIST_SHOW_ROLE_STYLE);
listView->addItems(items);

QPushButton* btn = new QPushButton(tr("Ok"), this);
btn->setGeometry(175, 265, 50, 30);
btn->setStyleSheet(FREQ_MODAL_BTN_STYLE);
connect(btn, SIGNAL(clicked()), this, SLOT(Close()));
}


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 ...

spirit
9th December 2009, 09:36
can you attach minimal compilable example which reproduces the problem?

wysota
9th December 2009, 09:59
I'd start by using layouts in your program. Next I'd try if removing the style sheet fixes the problem.

trallallero
9th December 2009, 11:21
Sorry I was in a meeting ...

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


#define ROLES_WIDGET_STYLE \
"color: black;" \
"font: bold;" \
"border: 2px solid black; " \
"border-radius: 5px; " \
"padding: 0px; " \
"background-color: rgb(200, 200, 200);"



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 ??? :confused:

AD
9th December 2009, 11:53
background-color: rgb(200, 200, 200);

Should you try this string:


background-color: #C8C8C8;
?

wysota
9th December 2009, 12:06
You should probably style the scrollbar's groove as well.