1

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); }");
}
Community
  • 1
  • 1
Sumeet
  • 8,086
  • 3
  • 25
  • 45

1 Answers1

3

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.

G.M.
  • 12,232
  • 2
  • 15
  • 18
  • But I have 1 problem. Its running fine now but the color of the text box is not changing. – Sumeet Oct 06 '16 at 17:26
  • Again, without more code it's difficult to tell, but... you appear to be using `m_textEdits[row][col].styleSheet()` immediately *before* setting it. – G.M. Oct 06 '16 at 17:51