PDA

View Full Version : How to remove Scroll bar of QCombo Box



RENOLD
15th February 2012, 05:32
I am able to hide the scroll bar arrow of the combobox using following line,


comboBox->setStyleSheet("QComboBox::drop-down::down-arrow {image:url}");


but my problem is that when I hide this arrow the space for this arrow in to the comboBox remain there so the letter which I enter in to the comboBox made off-centre,
So how can I remove this space in to the comboBox and show my letter centre,
Here I attached the picture, through the help of this picture you can clearly understand my problem,
7405

kinjalp
15th February 2012, 06:28
Hi ,

I REMOVE THE DOWN ARROW BUT I UNABLE TO REMOVE THE SIDE BAR THAT IS GIVEN IN THE COMBO BOX ANY OPTION FOR THAT ...

SOMEONE TELL ME THAT WHY U NOT USE TEXT EDIT OR LINT EDIT BUT I WANT TO GIVE ITEMS OPTION TO THE COMBO BOX ...

SEE IN THE BELOW FIG...7406

ALSO I WANT COLOUR CHANGE STYLE SHEET IS THERE WITH THE COMBO BOX...BOTH THE STYLE SHEET IS NOT WORKABLE TOGETHER...

comboBox->setStyleSheet("QComboBox::down-arrow {image: none;}QComboBox::down-arrow:on {image: none;};");
comboBox->setStyleSheet(QString::fromUtf8("border-color: rgb(255, 255, 127);\n""selection-background-color: rgb(255, 255, 127);\n""background-color: rgb(255, 255, 255);\n"""));

PLEASE HELP ME OUT IN THAT ...

KINJAL

Lykurg
15th February 2012, 07:09
Hm, is this task homework you have to do?

And you won't find an easy solution, because removing the "drop down" from a combobox is nonsense (like having a button without a click-able area). So no build in solution for that, but you can subclass the style and change the drawing there. Or use a proxy style.

ChrisW67
15th February 2012, 07:12
Perhaps you really want a QLineEdit, QCompleter and QValidator.

wysota
15th February 2012, 11:00
Or perhaps you don't want to use widgets at all. This looks more like a platform game than a UI of a utility program.

RENOLD
15th February 2012, 12:23
Thank you all for your valuable reply, I fill that I can solve my this problem using QLineEdit, I make my code through this,

Now I wanted to know that how to read value which i return inside the QLineEdit,
I try this, but it didn't work,

QString *a;
a=LineEdit->text();
qDebug("%s",a);

but it shows the error can not convert QString to QString in assignment,


Then I try this
qDebug("%s",LineEdit->text());
can not pass object of non trivially copyable type.

So please suggest me how can I read the value of LineEdit....

wysota
15th February 2012, 12:26
Are you sure the message didn't say it couldn't convert QString to QString* in assignment?

RENOLD
15th February 2012, 12:28
yes wysota..... is there any other way through which i can get this value???

wysota
15th February 2012, 12:30
Do you understand the difference between QString and QString*?

RENOLD
15th February 2012, 12:40
Yes I know it very well but it didn't work so i try QString *......
Have you any solution how to read value which was written inside the LineEdit....?????????????????????????????????????? ???????????????????

wysota
15th February 2012, 13:53
Yes I know it very well
So why are you trying to assign QString object to QString pointer? You read the value properly, using QLineEdit::text() but then you fail to use it correctly by trying to assign it to a pointer.

RENOLD
16th February 2012, 05:45
Hello friends Thanx for your replies,
I make my application using following code,



QString p;
p=lineEditBox->text();

QStringList stringList= p.split("",QString::SkipEmptyParts);
for (int i = 0; i < stringList.size(); i++)
{
if(i==stringList.size()-1)
{
lineEditBox->clear();
lineEditBox->setText(stringList.at(i));
}
}

... :)

Lykurg
16th February 2012, 08:01
for (int i = 0; i < stringList.size(); i++)
{
if(i==stringList.size()-1)
{
lineEditBox->clear();
lineEditBox->setText(stringList.at(i));
}
}
I don't try to find nice words: This horrible. Do you understand what this code does? Do you really think you need a loop to set the last word of an array to your line edit. Also why are you clearing the edit before setting a new text? With setting a new text, line edit clears itself automatically.

RENOLD
16th February 2012, 10:32
Yes lykurg I complete my task using this....
If you have any other simple suggestion then please write it..... :)

wysota
16th February 2012, 10:33
Hmm... what is the purpose of this line?


QStringList stringList= p.split("",QString::SkipEmptyParts);

RENOLD
16th February 2012, 10:49
http://www.qtcentre.org/threads/45843-QString-into-QStringList?highlight=qDebug

I got this solution from above thread.....

wysota
16th February 2012, 13:22
But this "solution" does something much different than your code. So again, why did you put this line there?