How to show rich text in the QCombobox.lineEdit()? or how to replace the lineedit in qcombobox with textedit? - pyqt

i have this working example
now i want to be able to edit the QLineEdit and highlight items that are not in the dropdown listview,(eg. red background color) , and add auto complete feature. from my understanding, the only viable way is making a custom widget, with a QTextEdit and a listView ( since qlineedit can't display html ?)
edit: eg I have India,China in the lineEdit, but i only want China's bg color to be red since it's not in the dropdown items list
is there an easier way other than this? thanks !
the code is here: http://pastebin.com/WGrj3ud5
and here : http://www.barishcb.com/?p=426

For the auto-completion, you need to add a QCompleter to your QlineEdit
For the red background, you can dynamically change the style sheet of the QLineEdit:
# in case of item not in the dropdown listview:
self.lineEdit.setStyleSheet("background-color: rgb(255, 0, 0);")
# otherwise:
self.lineEdit.setStyleSheet("")

Related

How to change the style of CComboBox scrollbar in MFC

I want to change the style of scrollbar of CComboBox. I can only change the selected item and background of dropbox, but haven't found any way to change the default style of scrollbar.
And is there any way to get the index of the current item shown on dropbox, so that I can draw my own scrollbar?

How can i change color of text of spinner?

I want to change the color of the default text in the spinner in dialog mode. If the text is "Select Gender" only its color change and others will be set as default. Is this possible?
Yes it is possible. You don't show anything you've tried and perhaps that's because you don't know whee to begin?
Have a read of this, Beginners CSS
It will help you get started with styling elements in Html documents using Cascading Style Sheets (CSS).

Is there a way of adding a scrollbar horizontally and vertically to a Text Input in Kivy?

I am new to Kivy and Pyhton and I want to put a scrollbar horizontally and vertically to a Text Input. I don’t want to use a ScrollView, because I am making a desktop app and it is not that intuitive as the user has to click and drag up and down or sidewards in the Text Input". I also found on the internet how to make a draggable scrollbar using a slider (https://github.com/kivy/kivy/wiki/A-draggable-scrollbar-using-a-slider), but I have’t been able to add it to the Text Input. Could anyone help me please?

qt4 - change the color of text cursor in a qlineedit?

I've subclassed qlineedit and written a custom line edit which has a default text. The default text is grayed out until the user starts to write some text into it. also the line edit has a time mask input. it only accepts inputs in range of 23:59:59.
the problem is when the line edit is empty and the default text is displayed in gray color, the cursor is also gray. I'd like to know how i'm able to change the cursor color to black while the default text is in gray color.
I have tried to override the paintevent. i saw the source code of qlineedit and saw that the QLineControl::DrawCursor is responsible for drawing the cursor in paintevent. but i have no idea how to change the pen color so it can effect the cursor color. Any ideas on how to do that? tnx.
void QCustomLineEdit::paintEvent(QPaintEvent * pe)
{
QLineEdit::paintEvent(pe);
QPainter painter;
painter.begin(this);
painter.setPen(Qt::red);
painter.end();
}
QLineEdit has a property named placeholderText which you can use to set the grayed text to be displayed when there is no text in the edit box. The cursor color is not changed and when you start typing the placeholder text disappears.

How to make selected QTableWidget row bold in pyqt

I want to know is it possible to make a stylesheet to make the contents in selected row bold.
i am using self.tw.setSelectionBehavior(QAbstractItemView.SelectRows) to set table to select entire row instead of cell. But i dont want any backgroung color to be changed instead it font should be bold.
How can i achieve this....?
This is a python style code
font = QFont()
font.setBold(True)
self.ui.tableWidget.item(row_index, col_index).setFont(font)
In C++, we would create an onTableEdited() slot, connect it to the itemSelectionChanged() event, and then use table->item(x,y)->setFont() with something like
QFont font;
font.setBold(true);
font.setWeight(75);
You can also set a QTableWidget to only allow the selection of rows.

Resources