Sumeet
Sumeet

Reputation: 8292

Why can't I use StyleSheet in QLineEdit object?

I have a class DragQLineEdit which inherits the QLineEdit.

I have defined an array as:

DragQLineEdit m_textEdits[FAVORITE_ROWS][FAVORITE_COLUMNS];

So I am able to generate a grid of edit text boxes. FINE.

But when I want to change the color say of the very first edit text box like this:

m_textEdits[0][0].setStyleSheet("QLineEdit { background: rgb(255,255,255); selection-background-color:rgb(233,0,0); }");

It gives me compiler error: no member named StyleSheet.

I did the above after reading the accepted answer of this question.

Basically, I have the following function:

void Favorites::mySlot(int r,int c,int row,int col)
{
    m_sendButtons[r][c].setText(m_sendButtons[row][col].text());
    m_sendButtons[row][col].setText("Send");

    m_textEdits[r][c].setStyleSheet(m_textEdits[row][col].StyleSheet);
    m_textEdits[row][col].setStyleSheet("QLineEdit { background: rgb(255,255,255); selection-background-color:rgb(233,0,0); }");
}

Upvotes: 0

Views: 710

Answers (1)

G.M.
G.M.

Reputation: 12879

You have...

m_textEdits[r][c].setStyleSheet(m_textEdits[row][col].StyleSheet);

It should be...

m_textEdits[r][c].setStyleSheet(m_textEdits[row][col].styleSheet());

Note the lower case 's' in styleSheet and parentheses after styleSheet signifying a function call.

Upvotes: 3

Related Questions