Skip to content
Qt 6.11 is out! See what's new in the release blog
  • 0 Votes
    7 Posts
    2k Views
    L
    @jsulm said in Storing QTextCharFormat and QColor to text file?: QTextStream & operator<<(const QTextCharFormat&) Hi, I have searched around how to write overloaded function for the operator, but I have not seen any example on the syntax you're using. I have declared QTextStream & operator<<(const QTextCharFormat&) in the class' header file, and in the source file, it should be something like this? QTextStream &SettingsDialog::operator<<(const QTextCharFormat &b) { stream << "font: " << b.font().toString() << " font-family: " << b.fontFamily(); return stream; } But I don't know where do I pass in the stream in the implementation.
  • 0 Votes
    6 Posts
    6k Views
    B
    @Sphinkie Wow, I had not noticed there is such a namespace since I'm still mainly using 5.12. If the constants are QColor objects as the doc says, then you should be able to use them directly like w->setForeground(QColorConstants::Red); w->setBackground(QColorConstants::Yellow);
  • Unable to assign QJSValue to QColor

    Unsolved QML and Qt Quick qcolor color qjsvalue c++ qml
    2
    0 Votes
    2 Posts
    4k Views
    p3c0P
    Hi @Mark81, As per the docs: Values must be simple constants; either strings (quoted and optionally within a call to QT_TR_NOOP), boolean values (true, false), numbers, or enumeration values (such as AlignText.AlignHCenter). So IMO a QColor cannot be assigned to the role myColor. And this in turn causes problem in the delegate.
  • 0 Votes
    2 Posts
    3k Views
    A
    It is not clear what you want to do. If you have a few buttons with different background color and connected signal clicked to slo6t lets day onClick(); and within such slot you want to find color of the button background which was clicked, first thing you need to find - which button was clicked. There are a few ways to find it. Simplest (not the best) is to call sender() within a slot. Cast ( use qobject_cast) to a QPushButton* ( or whatever your buttons are ), check its background if it is null. Why this way is not the best? It makes an assumption that slot is only called as a result of button click, which can't be guaranteed. It is better to use QSignalMapper.
  • 0 Votes
    18 Posts
    14k Views
    SGaistS
    Please share any bug report you are opening so that other may find them more easily.
  • 0 Votes
    7 Posts
    10k Views
    Chris KawaC
    @Matt-Chaput said: It seems odd for a moderator to be so belligerent, and act so condescending I'm sorry you feel that way but there's nothing I can do about it. I did try to provide a solution and explain why the other one was incorrect mathematically. Overlay mode would be useful for tinting e.g. icons with color, except it writes over transparent areas. That shortcoming of overlay mode is exactly the reason I suggested a two step approach instead. It breaks the problem into an alpha step and a color step. To be useful, it should multiply the alpha of the source and destination. If you wanted to do it in one step, yes. But, since there's no such mode in Qt, you can use the two step approach I suggested. [image: y4mSLDIlFmhljyEmfIErRwDDdatu_7R8fIvY0diVpGHJDvIEA5Q4Sk0aFJWqeIIyh7xyPCoA47sASoCV7JHHqImm1rfxwq-VXw9Fv9rrlksN1GeXAzDwj1fiLUycRcKgW6yV5Yzs9UFhIHKiaTEVglMDDfRFJ2IUwooKpB7fjTIfwZHisAry60dtC3gIAVjj690uF4uiQNR9RjLbkrp6QjRoQ] First is the original. Second is the mask created using the alpha of the source (CompositionMode_SourceIn). Third is the final result using overlay with the mask (CompositionMode_Overlay). As far as I can tell this is the result OP wanted, so can you explain what I got wrong? There's nothing sensible about Qt is doing. Qt is providing a pretty common set of composition modes implemented by various APIs, described e.g. here, here and here. If you know of a graphics API that does SourceIn+Overlay in one step could you point us to it?
  • 0 Votes
    7 Posts
    5k Views
    RatzzR
    @Chris-Kawa Thanks for the reply I messed up as you mentioned above . I used your code to make it work. thank you ;) QList<QColor> colors = { QColor::fromRgb(0,102,104,255), QColor::fromRgb(102,102,104,255), QColor::fromRgb(0,0,104,255) }; for(int i = 0; i < colors.size(); ++i) combo->setItemData(i, colors[i], Qt::BackgroundRole);
  • Value ranges in QColor

    General and Desktop qcolor natvis
    1
    0 Votes
    1 Posts
    1k Views
    No one has replied