Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    1. Home
    2. Tags
    3. qcombobox
    Log in to post

    • SOLVED QComboBox foregroun color not displayed in main widget
      General and Desktop • qcombobox • • Dariusz  

      3
      0
      Votes
      3
      Posts
      16
      Views

      @mrjj said in QComboBox foregroun color not displayed in main widget: Hi That sets the colors when drawn. It sounds like you want to also change the selection color ? https://forum.qt.io/topic/108718/change-qcombobox-popup-highlighted-item-background-color/12 So in a "human" test it works, if I set it, it works properly. But when I try to load my settings and set it "programmatically", even tho it says it sets pallets (btw I had to use ButtonText). Then it does not work... sigh. Its bananas. Will try to make simple examples.
    • UNSOLVED Display of QComboBox in QTableView
      General and Desktop • qcombobox qtableview c++ • • artwaw  

      4
      0
      Votes
      4
      Posts
      23
      Views

      @artwaw I'm not sure, but in addition to @SGaist you may also find you want to use https://doc.qt.io/qt-5/qabstractitemview.html#openPersistentEditor ?
    • UNSOLVED qcombobox drop-down list appears separately(QMDIArea and QMDISubwindow)
      General and Desktop • qcombobox qmdisubwindow qmdiarea qt5.14.2 • • sayan275  

      16
      0
      Votes
      16
      Posts
      91
      Views

      @Pl45m4 I'll try this...changing it's position
    • SOLVED How to properly create a two way connection with QComboBox?
      General and Desktop • qcombobox • • lansing  

      6
      0
      Votes
      6
      Posts
      112
      Views

      @SGaist Thanks I got it working, I don't know why it works but I'll take it. I updated the first post for future reference.
    • UNSOLVED How to change just one item of QCombobox editable by the user
      General and Desktop • c++ qcombobox • • learnist  

      4
      0
      Votes
      4
      Posts
      43
      Views

      @learnist Np :) However, for a real app, you should also consider the use case where users spell the new name wrong and want to delete it/edit it later to correct it.
    • UNSOLVED Styling of QLineEdit/QListView child of QCombobox on hover
      General and Desktop • qcombobox qlineedit qss • • mikael.larsson  

      3
      0
      Votes
      3
      Posts
      109
      Views

      @mikael-larsson Hi You could try an event filter on the Combobox and call the code for hover effect but if your effect is purely stylesheet based then i think you then must send it fake hover event to trigger it or something like that. You might also be able to subclass the combo and rig the paintEvent with if (someflag) option.state |= QStyle::State_MouseOver; to trigger hover on command from the event filter/ or combo hover or how you plan to trigger it.
    • UNSOLVED QComboBox with checkable items: issue with single checked item
      General and Desktop • qcombobox qcheckbox • • voltron  

      3
      0
      Votes
      3
      Posts
      153
      Views

      I think I have found a solution that is not necessarily complete (e.g. drive the combbox with keyboard). I add a boolean (e.g. mSkipToogle=false) at the same place than mSkipHide. I rewrite eventFilter (QObject* object, QEvent* event). bool CFilterCountryComboBox::eventFilter (QObject* object, QEvent* event) { QEvent::Type type = event->type (); if (object == view ()->viewport ()) { switch (type) { case QEvent::MouseButtonRelease : case QEvent::MouseButtonPress : mSkipHide = true; mSkipToogle = false; break; case QEvent::Hide : case QEvent::Show : mSkipToogle = true; break; default : break; } } if (type == QEvent::MouseButtonRelease && static_cast<QMouseEvent*>(event)->button () == Qt::RightButton) { return true; } return QComboBox::eventFilter (object, event); } Now rewrite toggleItemCheckState (int index) void CFilterCountryComboBox::toggleItemCheckState (int index) { if (!mSkipToogle) { QVariant value = itemData (index, Qt::CheckStateRole); Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt ()); setItemData (index, (state == Qt::Unchecked ? Qt::Checked : Qt::Unchecked), Qt::CheckStateRole); } else { mSkipToogle = false; } } It seems to work on Windows with Qt 5.12.7. Good luck
    • UNSOLVED fill combobox with query results, but also <select>
      General and Desktop • qcombobox qsqlquerymodel • • hobbyProgrammer  

      2
      0
      Votes
      2
      Posts
      114
      Views

      @hobbyProgrammer You cannot have a combo which is both bound to a model and has some extra row inserted into it --- it's one or the other. There are several possible approaches: Make your SQL query return a UNION ALL which includes a literal <select> as an extra row. Not really nice, because it makes the <select> be an extra row from the query. Copy the result set from the query into another model (you probably only need a list, perhaps a QStringList) where you insert the extra <select> as an item and use that as the combo's model. If you don't get a better example, this is the most obvious to code. Interpose a QIdentityProxyModel between the query model and the combo, and add the extra row there. I suspect this is the way it's supposed to be done(?).
    • UNSOLVED Filtering and sorting on QCompleter
      General and Desktop • qcombobox qcompleter • • Zee_07  

      1
      0
      Votes
      1
      Posts
      86
      Views

      No one has replied

    • UNSOLVED QComboBox and QAbstractSpinBox custom stylesheet affects arrow buttons
      General and Desktop • stylesheet qcombobox gradient qabstractspinbo • • sadeq  

      1
      0
      Votes
      1
      Posts
      167
      Views

      No one has replied

    • UNSOLVED QComboBox with QCompleter: multiple FocusIn event Issue
      General and Desktop • qwidget qcombobox focus issue • • Zee_07  

      1
      0
      Votes
      1
      Posts
      184
      Views

      No one has replied

    • UNSOLVED Settings widget into focus programmatically.
      General and Desktop • qwidget qtreeview qcombobox • • Dariusz  

      9
      0
      Votes
      9
      Posts
      659
      Views

      That article answers quite a few questions I had about that scenario, woah nice thanks! But... I kinda like the idea of more "control"... somehow, creating the widget this way allow the user to resize it which won't be possible using a popup, so I would like to get the focus to work properly... TIA
    • SOLVED QComboBox & QAbstractItemModel - editable/filtering
      General and Desktop • qcombobox qabstractitemmo • • Dariusz  

      3
      0
      Votes
      3
      Posts
      381
      Views

      @SGaist Awesome thanks! I think I can get it to do my bad biding now :- )
    • UNSOLVED Dynamically fit QComboBox popup height to the (dynamically changing) count of items
      General and Desktop • qcombobox resize qlistview item view • • AloyseTech  

      9
      0
      Votes
      9
      Posts
      1437
      Views

      @AloyseTech IIRC hidePop() will reset the Popupwidget, so maybe hijack the add/remove process. Call hidePopup before adding are removing item and call showPopup afterwards?
    • UNSOLVED How to make QTableView with QComboBox in one column.
      General and Desktop • c++ qt5 qtableview qcombobox • • arkadiusz97  

      2
      0
      Votes
      2
      Posts
      958
      Views

      What's the problem replacing the QSpinBox with a QComboBox in the example? Did you even try?
    • SOLVED StyleSheet & QComboBox, height trouble
      General and Desktop • qcombobox qstylesheet qabstractitemvi min-height • • J.Hilk  

      10
      0
      Votes
      10
      Posts
      5727
      Views

      @J.Hilk ok then you can follow the suggestion from @mrjj (in case you would have set a custom model you would have need to handle the Qt::SizeHintRole in your data() method) or try to set a QStyledItemDelegate to the view and use your stylesheet.
    • SOLVED Update combobox data from model
      General and Desktop • qcombobox qsqltablemodel • • rudag  

      8
      0
      Votes
      8
      Posts
      2578
      Views

      I did this: ui->comboBox->clear(); ((QSqlTableModel*)ui->comboBox->model())->select(); And it's working!
    • SOLVED QComboBox lineEdit value not inserted in selection list
      General and Desktop • qcombobox extend selectio selection list • • koahnig  

      2
      0
      Votes
      2
      Posts
      637
      Views

      @koahnig Not directly. You have to fake it: bool eventFilter(QObject* watched, QEvent* event) { if( watched == comboBox ) // or watched->inherits("QComboBox") ?? { // you may want to do additional checks here for a generic solution (like the combobox is really editable, it has a insert policy set, etc) switch( event->type() ) { case QEvent::FocusOut: { QKeyEvent keyEvent( QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier ); QCoreApplication::instance()->sendEvent( watched, &keyEvent ); } break; } } return BaseClass::eventFilter(watched,event); }
    • UNSOLVED Signal Not Found for QComboBox
      General and Desktop • qcombobox signal • • SolaVitae  

      3
      0
      Votes
      3
      Posts
      1891
      Views

      Hi @SolaVitae , as suggested by @jsulm you have to delete param name in connect signal, you can keep const & Your connect will be then: connect(charactersBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(characterSelectedChange(const QString &)));
    • SOLVED QTabBar with QComboBox
      General and Desktop • qcombobox qtabbar • • tgru  

      6
      0
      Votes
      6
      Posts
      1447
      Views

      Right, that's the best solution if you are using a QTabWidget.
    • SOLVED QCombobox with key and value
      QML and Qt Quick • qml qt quick model qcombobox key and value • • tamlong0205  

      4
      0
      Votes
      4
      Posts
      1486
      Views

      I had create a model with key and value and pass it to qml, it worked!!! Sorry for late reply. Thank you @raven-worx
    • UNSOLVED How to add QComboBox and TextField inside TreeView with delegate QML?
      QML and Qt Quick • qml qcombobox delegate treeview qabstractitemmo • • tamlong0205  

      4
      0
      Votes
      4
      Posts
      2684
      Views

      @tamlong0205 I think most of this can be done from C++ side. You can add a function in the model which can return what type is the data for current index. This function will be called from QML and depending upon its value use a Loader to load the specific delegate. Perhaps setting currentIndex in Component.onCompleted handler ? Create a C++ function which will store in info in the model itself i.e When you change the index in ComboBox call this function and update the value there and may be maintain a role to store this update.
    • UNSOLVED Position of a Qt Combobox dropdown
      General and Desktop • qcombobox qlistview • • sunil.nair  

      10
      0
      Votes
      10
      Posts
      6057
      Views

      I apologise for the delay in response. The question was to make sure that the combobox always pops up in a given direction or position.
    • SOLVED how to add item QComboBox with QVideoFrame::PixelFormat?
      General and Desktop • qcombobox text strange additem pixelformat • • pauledd  

      7
      0
      Votes
      7
      Posts
      1979
      Views

      Ok, thanks a lot! Marked as solved!
    • UNSOLVED QComboBox align text stylesheet?
      General and Desktop • stylesheet qcombobox text align alignment • • pauledd  

      8
      0
      Votes
      8
      Posts
      7055
      Views

      QComboBox {background-color:rgb(190,190,190);color:black;padding-left: 10px;padding-right: 30px;border-style: solid;border-width: 0px;} "padding-left: 10px;" the padding will shift the combo-box displayed content form the left edge QComboBox::drop-down {subcontrol-origin: padding; subcontrol-position: top right;width: 40px;border: 0px ;} "subcontrol-position: top right;" and the above will position wot text to the right. Hopefully this helps.
    • UNSOLVED QComboBox with transparent dropdown
      General and Desktop • qt5 stylesheet qcombobox css drop-down • • Sebbo  

      5
      0
      Votes
      5
      Posts
      3478
      Views

      @VRonin With the provided code the whole dropdown list will be invisible. Do you know how to keep the items unaffected?
    • UNSOLVED Program crashes when calling QComboBox::clear() on a non-empty Combo Box
      General and Desktop • qcombobox crash qcombobox crash • • PurityLake  

      9
      0
      Votes
      9
      Posts
      3611
      Views

      @mrjj said: this->ui->personComboBox then pointer must be corrupt?
    • SOLVED QComboxBox different sizes for button and popup
      General and Desktop • qcombobox • • pablolito  

      12
      0
      Votes
      12
      Posts
      4060
      Views

      @raven-worx Thanks a lot ! This does exactly what I want !
    • Custom QWidgetAction To Differ on Vertical QToolBar and/or Different QToolButton Styles
      General and Desktop • qcombobox qtoolbar style qtoolbutton qwidgetaction • • Erika  

      3
      0
      Votes
      3
      Posts
      1157
      Views

      @SGaist Thanks. That's definitely another option. I suppose these approaches are as good as it gets for having a toolbar item auto-adjust to horizontal vs. vertical. Thanks again.
    • UNSOLVED QComboBox long item text breaks layout
      General and Desktop • qcombobox qscrollarea qformlayout • • the_  

      4
      0
      Votes
      4
      Posts
      2650
      Views

      @Rondog I was already thinking of setting the maximum width for each combobox but when creating the comboboxes I dont know the width of the scrollareas viewport. @SGaist Will try that, seems to be the more nice solution :) Thanks
    • UNSOLVED Qt5.6: How to disable the QComboBox's Up/Down arrows and show all items?
      General and Desktop • qcombobox • • cgripeos  

      2
      0
      Votes
      2
      Posts
      2503
      Views

      Solution that works for me is to call unpolish and polish on combo box: auto cb = new QComboBox(this); cb->setItemDelegate( new QStyledItemDelegate); style()->unpolish(cb); style()->polish(cb);
    • UNSOLVED How to sub stylesheet ?
      General and Desktop • stylesheet qcombobox qlistview qstyle qcheckbox • • _compiler  

      5
      0
      Votes
      5
      Posts
      2015
      Views

      @_compiler said: thanks.
    • SOLVED QCombobox with clearEditText ()
      General and Desktop • qcombobox clearedittext • • gabor53  

      3
      0
      Votes
      3
      Posts
      870
      Views

      @elveatles Thank you. You were right.
    • UNSOLVED Exiting QComboBox and reading content
      General and Desktop • qcombobox • • gabor53  

      4
      0
      Votes
      4
      Posts
      1106
      Views

      Hi, Isn't QComboBox::activated what you are looking for ?
    • UNSOLVED Differend ID-column and display-column in QCombobox
      General and Desktop • qcombobox • • Mr. Kibu  

      8
      0
      Votes
      8
      Posts
      2254
      Views

      It shouldn't belong to the Purchase table. That table should only contain items whether they come from a store or somewhere else is not something that that table should handle.
    • [Solved] Check if value is part of the list in qcombobox
      General and Desktop • qcombobox • • Mr. Kibu  

      5
      0
      Votes
      5
      Posts
      9307
      Views

      Thank you to the_ and SGaist! I realised it like the_ explained. In my case it is the easiest way and it works (in a combobox with a list of values from a related table, I want to know if the entered string is part of the list and if not (index = -1) I open a dialog to add a new value in the related table). But I admit, QCompleter is also a smart solution. Maybe in the future...
    • QCombobox scrolling in touchscreen device
      General and Desktop • qcombobox scroll touch screen • • marlenet15  

      5
      0
      Votes
      5
      Posts
      3606
      Views

      I solve it I use the same thing ui->comboBox->view()->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); if there is a better solution please post it Thanks
    • SOLVED QComboBox with icons but no text - how?
      General and Desktop • qcombobox qicon align • • wavelike  

      6
      0
      Votes
      6
      Posts
      4622
      Views

      @wavelike said: don't they use QComboBox-like widgets to offer different colors, brush thickness etc? Hm, I guess that's true, but I'd say it has more to do with QMenus and QToolButtons than QComboBox. But then again they are indeed similar in some ways. Oh well, the important thing is it's doable and quite easy ;)
    • UNSOLVED How can I pass data of QComboBox between classes?
      General and Desktop • qcombobox qt 4.8.5 • • roseicollis  

      6
      0
      Votes
      6
      Posts
      1892
      Views

      Yes, it's clearer. In that case I'd create a subclass of QComboBox with a property that would return content of data.