PDA

View Full Version : Bug Selection MacosX QlineEdit and QSpinBox with Style Sheet



bgougeon
17th April 2009, 22:48
Hello,

I'm experiencing some visual issues on Qt4.5 with QLineEdit and QSpinBox, this only on MacOSX, on windows it works great.
As soon as I apply a style sheet, in my case a background image for my container widget, the selection gets confused and no text is shown even if I type. And once I select an other field, then the text wrote before appears.
It does the same with SpinBox, the text is not updated when I click on the arrow, but once I select an other field, the text appears.

It doesn't come from my code since I'm using QtDesigner for the form design. As soon as I delete the style, the selection works.

I've try to figure out what is the reason of this, I guess it is some issues with the transparency and macstyle.

I hope someone already experienced this problem and can help me fixing it!

Thanks for your help,

Boris

bgougeon
21st April 2009, 18:49
I forgot to say that it is only when the widget is in a sub layout (or sub-widget with an horizontal layout). Like when I have few widgets on the same line in a parent layout, the text won't show up.


groupBox = new QGroupBox(LogInScreen);
groupBox->setObjectName(QString::fromUtf8("groupBox"));
groupBoxLayout = new QVBoxLayout(groupBox);
groupBoxLayout->setObjectName(QString::fromUtf8("groupBoxLayout"));
titleLabel = new QLabel(groupBox);
titleLabel->setObjectName(QString::fromUtf8("titleLabel"));
titleLabel->setAlignment(Qt::AlignCenter);

groupBoxLayout->addWidget(titleLabel);

subTitleLabel = new QLabel(groupBox);
subTitleLabel->setObjectName(QString::fromUtf8("subTitleLabel"));
subTitleLabel->setAlignment(Qt::AlignCenter);

groupBoxLayout->addWidget(subTitleLabel);

middleSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);

groupBoxLayout->addItem(middleSpacer);

userInfoLayout = new QHBoxLayout();
userInfoLayout->setSpacing(25);
userInfoLayout->setObjectName(QString::fromUtf8("userInfoLayout"));
userInfoLayout->setContentsMargins(0, -1, 0, -1);
leftlSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

userInfoLayout->addItem(leftlSpacer);

loginPasswordLayout = new QFormLayout();
loginPasswordLayout->setObjectName(QString::fromUtf8("loginPasswordLayout"));
loginPasswordLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedField sGrow);
loginPasswordLayout->setVerticalSpacing(15);
loginLabel = new QLabel(groupBox);
loginLabel->setObjectName(QString::fromUtf8("loginLabel"));

loginPasswordLayout->setWidget(0, QFormLayout::LabelRole, loginLabel);

loginLineEdit = new QLineEdit(groupBox);
loginLineEdit->setObjectName(QString::fromUtf8("loginLineEdit"));

loginPasswordLayout->setWidget(0, QFormLayout::FieldRole, loginLineEdit);

passwordLabel = new QLabel(groupBox);
passwordLabel->setObjectName(QString::fromUtf8("passwordLabel"));

loginPasswordLayout->setWidget(1, QFormLayout::LabelRole, passwordLabel);

passwordLineEdit = new QLineEdit(groupBox);
passwordLineEdit->setObjectName(QString::fromUtf8("passwordLineEdit"));
passwordLineEdit->setEchoMode(QLineEdit::Password);

loginPasswordLayout->setWidget(1, QFormLayout::FieldRole, passwordLineEdit);


userInfoLayout->addLayout(loginPasswordLayout);

forgotSomethingLayout = new QVBoxLayout();
forgotSomethingLayout->setSpacing(15);
forgotSomethingLayout->setObjectName(QString::fromUtf8("forgotSomethingLayout"));
forgotLoginLabel = new QLabel(groupBox);
forgotLoginLabel->setObjectName(QString::fromUtf8("forgotLoginLabel"));
forgotLoginLabel->setOpenExternalLinks(true);

forgotSomethingLayout->addWidget(forgotLoginLabel);

forgotPasswordLabel = new QLabel(groupBox);
forgotPasswordLabel->setObjectName(QString::fromUtf8("forgotPasswordLabel"));
forgotPasswordLabel->setOpenExternalLinks(true);

forgotSomethingLayout->addWidget(forgotPasswordLabel);


userInfoLayout->addLayout(forgotSomethingLayout);

rightSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

userInfoLayout->addItem(rightSpacer);


groupBoxLayout->addLayout(userInfoLayout);

middleSpacer_2 = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);

groupBoxLayout->addItem(middleSpacer_2);

buttonsLayout = new QHBoxLayout();
buttonsLayout->setObjectName(QString::fromUtf8("buttonsLayout"));
buttonsLeftSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

buttonsLayout->addItem(buttonsLeftSpacer);

okButton = new QPushButton(groupBox);
okButton->setObjectName(QString::fromUtf8("okButton"));
QSizePolicy sizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(okButton->sizePolicy().hasHeightForWidth());
okButton->setSizePolicy(sizePolicy);

buttonsLayout->addWidget(okButton);

cancelButton = new QPushButton(groupBox);
cancelButton->setObjectName(QString::fromUtf8("cancelButton"));
sizePolicy.setHeightForWidth(cancelButton->sizePolicy().hasHeightForWidth());
cancelButton->setSizePolicy(sizePolicy);

buttonsLayout->addWidget(cancelButton);


groupBoxLayout->addLayout(buttonsLayout);


mainLayout->addWidget(groupBox);

bottomSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);

mainLayout->addItem(bottomSpacer);


If needed I can upload a screenshot of the bug.

Thanks for your help!
Boris

bgougeon
23rd April 2009, 17:54
up, still haven't figured out why!

Nocuous
29th April 2009, 19:05
I am having the same issue. Once setStylesheet("anything other than empty"); is called the spin boxes and line edits malfunction.

Mac Os X using Qt 4.5 LGPL
My steps to reproduce:
Call setStylesheet("QLabel{background:blue;}")
Click in one spin box and the text etc works properly.
Click in another spin box in another layout and notice the text does not appear to be editable however typing does change the value without any feedback other than valueChanged being called however, the actual text area does not update until the focus has changed to another control.

Nocuous
29th May 2009, 17:45
Possible work around:
I have found this bug does not exist when you disable the Mac focus rectangle on each of the text based controls.

Example
control->setAttribute(Qt::WA_MacShowFocusRect, false);

bgougeon
8th June 2009, 22:16
Hi Nocuous!

This bug has been fixed in the last qt update. You can download it here (http://get.qtsoftware.com/qtsdk/qt-sdk-mac-opensource-2009.02.dmg), this was a known issue in Qt.
Boris