سؤال

I started using Qt Creator some time ago and I managed to create my first GUI application by coding. However I don't like the standard buttons so I created one in designer mode but I can't figure out how to replace the old buttons with the one I created. Can someone give me a hint on how to do that?Thanks in advance!Here's my calculator application output : calculator

هل كانت مفيدة؟

المحلول

  1. Whatever properties you changed in designer mode to create your own button, you can take those change on your old buttons, if the old buttons are created in ui form (in designer).

  2. Agree with the comment, if all you alter on buttons are about appearance, you can apply style sheet to all your buttons on calculator throught:

    QPushButton#buttonObjectName { border: none; border-radius: 0; background... }

or

QWidget#CalculatorObjectName QPushButton // this applies style to all button on calculator
{
}
  1. (Not suggested) subclass QPushButton, overwrite what every protected functions you want to alter, and promote QPushButtons in your designer to your subclass name. i see no necessary in such solution.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top