Results 1 to 17 of 17

Thread: How to remove Scroll bar of QCombo Box

  1. #1
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default How to remove Scroll bar of QCombo Box

    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,
    Screenshot.png

  2. #2
    Join Date
    Dec 2011
    Posts
    13
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: How to remove Scroll bar of QCombo Box

    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...Screenshot-1.png

    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-arrown {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

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to remove Scroll bar of QCombo Box

    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.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to remove Scroll bar of QCombo Box

    Perhaps you really want a QLineEdit, QCompleter and QValidator.

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

    Default Re: How to remove Scroll bar of QCombo Box

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


  6. #6
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default Re: How to remove Scroll bar of QCombo Box

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

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

    Default Re: How to remove Scroll bar of QCombo Box

    Are you sure the message didn't say it couldn't convert QString to QString* in assignment?
    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.


  8. #8
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default Re: How to remove Scroll bar of QCombo Box

    yes wysota..... is there any other way through which i can get this value???

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

    Default Re: How to remove Scroll bar of QCombo Box

    Do you understand the difference between QString and QString*?
    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.


  10. #10
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default Re: How to remove Scroll bar of QCombo Box

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

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

    Default Re: How to remove Scroll bar of QCombo Box

    Quote Originally Posted by RENOLD View Post
    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.
    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.


  12. #12
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default Re: How to remove Scroll bar of QCombo Box

    Hello friends Thanx for your replies,
    I make my application using following code,


    Qt Code:
    1. p=lineEditBox->text();
    2.  
    3. QStringList stringList= p.split("",QString::SkipEmptyParts);
    4. for (int i = 0; i < stringList.size(); i++)
    5. {
    6. if(i==stringList.size()-1)
    7. {
    8. lineEditBox->clear();
    9. lineEditBox->setText(stringList.at(i));
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    ...
    Last edited by wysota; 16th February 2012 at 10:32. Reason: missing [code] tags

  13. #13
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to remove Scroll bar of QCombo Box

    Quote Originally Posted by RENOLD View Post
    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.

  14. #14
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default Re: How to remove Scroll bar of QCombo Box

    Yes lykurg I complete my task using this....
    If you have any other simple suggestion then please write it.....

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

    Default Re: How to remove Scroll bar of QCombo Box

    Hmm... what is the purpose of this line?

    Qt Code:
    1. QStringList stringList= p.split("",QString::SkipEmptyParts);
    To copy to clipboard, switch view to plain text mode 
    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.


  16. #16
    Join Date
    Feb 2012
    Posts
    27
    Thanked 2 Times in 2 Posts

    Default Re: How to remove Scroll bar of QCombo Box

    http://www.qtcentre.org/threads/4584...ghlight=qDebug

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

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

    Default Re: How to remove Scroll bar of QCombo Box

    But this "solution" does something much different than your code. So again, why did you put this line there?
    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. How we increase the width of Scroll bar of QCombo Box
    By rajeshclt3 in forum Qt Programming
    Replies: 6
    Last Post: 16th August 2011, 09:53
  2. Set Default text in QCombo box
    By daarsh in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2011, 10:38
  3. Need help on setting up Defult text on QCombo box
    By Askar in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2011, 10:50
  4. QDial disabling key scroll and mouse wheel scroll
    By ldg20 in forum Qt Programming
    Replies: 2
    Last Post: 2nd June 2010, 23:05
  5. Qcombo box
    By nErnie in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2006, 00:56

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.