Когда разрабатываете свой GUI с помощью PyQt для какого-либо софта бывает необходимо позаимствовать цвета из текущего стиля интерфейса. Например, чтобы правильно раскрасить свои виджеты, подогнав их по цвету. Ведь бывает, что ваш GUI используется в разных софтах. Причём некоторые со светлой темой а другие с тёмной.
По умолчанию стили наследуются, но если вы задаёте какую-либо раскраску для части виджета через свой styleSheet, то требуется ссылаться на цвета текущего стиля.
Как это сделать? Как получить нужный цвет из палитры имеющегося стиля? Это достаточно просто, нужно использовать класс QPalette и его роли.
Например, мне нужно достать цвет текста из одного виджета и применить его в другом как цвет фона (не важно зачем именно так, просто захотелось😊).
Получаем палитру виджета и сразу достаём нужный цвет, указав его роль.
from PySide2.QtGui import QPalette
color = main_window.palette().color(QPalette.Text)
теперь можем использовать этот цвет в стилях
my_widget.setStyleSheet(f'background-color: {color.name()};')
Готово, мы динамически переопределили дефолтный стиль используя текущий стиль окна!
На самом деле есть запись покороче, в одну строку и без лишних переменных. Не очень-то по правилам CSS, но Qt это понимает.
my_widget.setStyleSheet('background-color: palette(Text);')
Этот способ не подходит если вам нужно как-то модифицировать цвет перед применением в своих стилях. В этом случае потребуется первый способ.
Зато он прекрасно сработает в файле .qss, то есть не придётся в коде прописывать раскраску отдельных элементов через ссылки на палитру, всё красиво сохранится в отдельном файле .qss!
QListView#my_widget::item:selected {
background: palette(Midlight);
}
Про имеющиеся роли можно почитать здесь🌍
#qt#tricks
Good Morning Traders...
Be ready for our weekly report coming soon 👌
FxSignals_Gold analyst brutally butchered the market this week with unbeatable killing result and performance 😱 Our daily and consistent performance speaks for itself... We take maximum pride in what we do💃🕺
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
Dear Traders,
Welcome each and everyone to a new trading week, we commence this week in the name of God 🙇♂️ a fruitful, buoyant and pips_gain week to everyone.
Huge pips ahead this coming week. Lots of scanned trade setups. FxSignals_Gold analyst would be crushing the market.
Lots of accounts would be doubled stay tuned mates, let's help you grow.
Let’s make this the best week of your trading career so far... Let's catch you some serious 💵💴
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FrxMaster_Gold
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Good Morning Traders...
Be ready for our weekly report coming soon 👌
FxSignals_Gold analyst brutally butchered the market this week with unbeatable killing result and performance 😱 Our daily and consistent performance speaks for itself... We take maximum pride in what we do💃🕺
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
Dear Traders,
Welcome each and everyone to a new trading week, we commence this week in the name of God 🙇♂️ a fruitful, buoyant and pips_gain week to everyone.
Huge pips ahead this coming week. Lots of scanned trade setups. FxSignals_Gold analyst would be crushing the market.
Lots of accounts would be doubled stay tuned mates, let's help you grow.
Let’s make this the best week of your trading career so far... Let's catch you some serious 💵💴
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FrxMaster_Gold
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Happy Tuesday My Champions! 😎
Success in trading starts with the right mindset and honing our skills. Let's focus on improving our knowledge and decision-making abilities. Embrace the hustle and pray for wisdom.
Thank you, God and the Universe, for guiding us. Here's to a profitable and wise trading day ahead! 🙏
☎️Forex Master
#AccountManagement
#PropFirmChallenge&Verification✅
Good Morning Traders...
Be ready for our weekly report coming soon 👌
FxSignals_Gold analyst brutally butchered the market this week with unbeatable killing result and performance 😱 Our daily and consistent performance speaks for itself... We take maximum pride in what we do💃🕺
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
Happy Friday My Champions! 😎
Every great dream begins with a dreamer ✨
Always remember, you have within you the strength, patience, and the passion to reach for the stars to change the world! 👌
Believe in yourself & have faith in your abilities. Don't let nobody steal your dream! 🔥
Wish it, plan it, do it!
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
FxSignals_Gold Weekly Report - ( From 28/10/24 To 01/11/24)
90% Success rate, +916Pips delivered this week🔥🔥
Quick Pips Summary⤵️
⚡️Net Profit: +916Pips
🔎Total Signals: 16
⏳Running Signals: 1
⚠️Losing Pips: -100 Pips
🎯Winning Pips: +1,016Pips
🏆Total Net Profit Gained: +916Pips
We build loyalty, Real loyalty. We extract every pip we can from the markets, precision!
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FrxMaster_Gold
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Dear Traders,
Welcome each and everyone to a new trading week, we commence this week in the name of God 🙇♂️ a fruitful, buoyant and pips_gain week to everyone.
Huge pips ahead this coming week. Lots of scanned trade setups. FxSignals_Gold analyst would be crushing the market.
Lots of accounts would be doubled stay tuned mates, let's help you grow.
Let’s make this the best week of your trading career so far... Let's catch you some serious 💵💴
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FxGoldHubClientSupport
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
FxSignals_Gold Weekly Report - ( From 21/10/24 To 25/10/24)
80% Success rate, +603Pips delivered this week🔥🔥
Quick Pips Summary⤵️
⚡️Net Profit: +603Pips
🔎Total Signals: 13
⏳Running Signals: 0
⚠️Losing Pips: -150 Pips
🎯Winning Pips: +753Pips
🏆Total Net Profit Gained: +603Pips
We build loyalty, Real loyalty. We extract every pip we can from the markets, precision!
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Good Morning Traders...
Be ready for our weekly report coming soon 👌
FxSignals_Gold analyst brutally butchered the market this week with unbeatable killing result and performance 😱 Our daily and consistent performance speaks for itself... We take maximum pride in what we do💃🕺
#PropFirmChallenge&Verification✅
#AccountManagement👨🏻💻
Stay tuned for the update 👊
#TheGoldMaster🦾
FxSignals_Gold Premium VIP Daily Performance 🔔
Wednesday - 05/02/2025
Swing Trade » 🟠Buy GBPAUD (-50Pips)
Swing Trade » 🟠Sell XAUUSD (+37Pips)
Scalp Trade » 🟠Sell XAUUSD (+30Pips)
Swing Trade » 🟠Buy GBPJPY (+32Pips)
Scalp Trade » 🟠Sell XAUUSD (+86Pips)
Scalp Trade » 🟠Sell XAUUSD (+39Pips)
Swing Trade » 🟠Buy XAUUSD (-50Pips)
Scalp Trade » 🟠Sell XAUUSD (+80Pips)
⚡️Net Profit: +208Pips
🔎Total Signals: 8
⏳Running Signals: 1
⚠️Losing Pips: 100 Pips
🎯Winning Pips: +308Pips
🏆Total Net Profit Gained: +208Pips
Always remember, never lose sight of your goals. Start Investing in your dreams. No matter how hard it gets, not matter what challenges you face, look forward and never ever give up!
Join the list of others who have found their success in forex with FxSignals_Gold VIP with very low and affordable subscription fee.
Starting from $49 per Month
For Question, Information,Feedback ...
Kindly Contact
☎️T.me/FrxMaster_Gold
#PropFirmChallenge&Verification✅
#FUNDEDAccountManagement👨🏻💻