January 14, 2012

umen242 umen242
Ant Farmer
328 posts

QLabel doesn’t get transparent background and editable text even so i did set the right flags

 

Hello
i have QLable that i panting in QStyledItemDelegate item .
in the constructor i define :

  1. pLabel_title = new QLabel();
  2. pLabel_title->setTextFormat(Qt::PlainText);
  3. pLabel_title->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse);
  4. pLabel_title->setStyleSheet("QLabel { background-color : transparent; }");
  5. pLabel_title->setGeometry(rect);

and in the paint method i set the text and the Lable position

  1. QString Title = pItem->title();
  2.  pLabel_title->setText(Title);
  3.  QRect TextEditRect(option.rect.x()+THUMB_WIDTH+THUMB_WIDTH+PADDING, option.rect.y() ,
  4.             pLabel_title->width(), pTextEdit_title->height());
  5.  
  6.      QPixmap pixmap(pLabel_title->size());
  7. pLabel_title->render(&pixmap);

every thing is shown but the QLable background stay gray color ( the QStyledItemDelegate is gradient color)
and i can’t select or do any thing that the setTextInteractionFlags let me do .
i just see the text. what im doing wrong here ?

2 replies

January 14, 2012

leon.anavi leon.anavi
Mad Scientist
1048 posts

Have you see the article QWidget Semi-transparent Background Color [developer.qt.nokia.com] ? It shows how to make a QWidget semi-transparent and might give you a hint.

 Signature 

http://anavi.org/

January 14, 2012

umen242 umen242
Ant Farmer
328 posts

Hi thanks to the replay , i implement custom QLabel with this paintevent
but still it shows gray color . i suspect i messed something with the item background color
that i set to gradient , i dont know … its driving me crazy .

 
  ‹‹ [SOLVED] Qt app crashing calling QPainter begin() - segfaults internally calling glCreateShader      position in scene coordinates ››

You must log in to post a reply. Not a member yet? Register here!