0

In PyQt4, I want to present a QPushButton that looks like the down-arrow button in QComboBox. Feasible, and if so, how?

I don't need help getting my new widget-combination acting like a QComboBox (see below). I only want the QPushButton display/graphic to look like the down-arrow button in a QComboBox - and tips/code on how to overlay that graphic (especially if said graphic comes via a file) onto my own QPushButton.

More details, context:

I'm seeking to replace a QComboBox widget with a QLineEdit + QCalendarWidget, because QDateEdit isn't as customizable as I need (I think...). The thought is to place a QPushButton immediately adjacent (on the right-side) of the QLineEdit to make it things look like regular QComboBox as much as possible. Then said button will .exec_() the QCalendarWidget (which is technically wrapped by a QDialog).

Let me know if this doesn't make sense, and I can provide further or clarified context.

Johnny Utahh
  • 2,389
  • 3
  • 25
  • 41
  • It would be worth asking a separate question about whether the `QDateEdit` can be made to do what you want. I don't doubt a custom widget could be created as you describe here, but it may be a lot of work to make it behave/look exactly like a `QComboBox`. – three_pineapples Apr 22 '15 at 23:23
  • @three_pineapples Thanks for your note. Making my own widget gizmo appears to be easier (in the near term) than posting the question. And I'm growing further confident that QDateEdit can not come close to meeting my requirements. But I may post another question sometime later, maybe. Possibly with my finished-coded solution for the alternative. Additionally, for now at least, all I need is a button that _looks_ like a QComboBox down-arrow button. I can handle (I think) implementing all the functionality. It's only the aesthetics I'm worried about; I've updated the above question accordingly. – Johnny Utahh Apr 23 '15 at 05:08
  • All the back-end functionality is now working, and well. I now need to go figure out the button file/graphic (maybe I'll just screen-capture it from a running QComboBox), how to overlay said graphic on a QPushButton, and then how to align the QPushButton immediately adjacent to my calendar-enabled-QLineEdit (which is the "back-end functionality") widget. With no apparent answers for this, I'll be trying to investigate how to do this on my own. – Johnny Utahh Apr 27 '15 at 21:21

1 Answers1

2

You can try a QToolButton with no text and the arrowType property set to Qt.DownArrow. eg: myqtoolbutton.setArrowType(Qt.DownArrow).

Frodon
  • 3,684
  • 1
  • 16
  • 33
  • Excellent. It doesn't look exactly like a QComoboBox, but doesn't need to, and anyway it's darn close enough. Thanks @Frodon, this saved me a _lot_ of time trying to implement a much-less-elegant solution. To note: it's `Qt.DownArrow`, and I've edited your answer accordingly. – Johnny Utahh Apr 28 '15 at 05:26
  • Ok, so @Bryan rejected my edit. Seems like he's regularly rejecting edits, and I'm concerned he's not putting much thought or effort into his reviews--I realize he may have to review a lot of edits, and that may be cumbersome and difficult. Bryan, Frodon's answer has a slight technical fault, and it needs to be corrected. Please look at my edit more closely - thank you. – Johnny Utahh Apr 28 '15 at 05:32
  • @JohnnyUtahh I applied your edit (indeed I didn't check the namespace of `DownArrow`, thanks) – Frodon Apr 28 '15 at 09:30