Qt World Summit: Submit your Presentation


Get and set color of QAction by code not QSS ?



  • QPalette plt = ui->action->palette(); // not available
    QBrush brush = plt.color(QPalette::Text);
    QColor color = QColorDialog::getColor(brush.color(), this);
    if (color.isValid()) {
        plt.setColor(QPalette::Text, color);
        ui->action->setPalette(plt);
    }
    

  • Lifetime Qt Champion

    Hi,

    You don't, QAction has no "seeable body". It can be associated to a menu, a button but in itself it does not provide any graphical representation.


Log in to reply