html - How to provide multiple links in one cell of a QTableView -
I have although I you can create a custom You must set an item representative for a specific column: Now that you set in a rich text model text for specific column in a row, it will be displayed properly: QTableView in my project, in which many columns display data that contains hyperlinks I use a delegate class to set it so that when the cell is clicked in the column, it will open the linked page in the browser. This works great ... When only one page is being linked to a page For example, there may be a list of search values for mysite.com, where columns A, B, C, Etc. are worth. If user clicks on cell in this column with A, then it will open a hyperlink for mysite. Com / A (Again, this part works fine) However, now I need to add a column in which there are some things like "A, B", where A-B can search in the same cell Need to support links to which they click on. I'm searching online for a while and it seems that probably can not be done with a representative I have a line in a code somewhere in the
QTextBrowser , where I call it HTML I can do this by:
Caststring to show; For (int i = 0; i & lt; searchValueList.size (); i ++) {toShow.append ("` & lt; a href = \ "www.mysite.com/" + searchValueList.at (i ) + "\" `& Gt; the" + searchValueList.at (i) + "`
QTableView identify the HTML format or Rich text , and sorry I could not make that possible. what I'm trying to accomplish?
QItemDelegate to specific columns in which you can display rich text. representatives Person may like:
class Rich Text Diliaget Public QItemDelegate {public: RichTextDelegate (QObject * parent = 0); void paint (QPainter * painter, const QStyleOptionViewItem & amp; options, const QModelIndex & amp; index) const;}; Rich Tekstdeliget :: Rich Tekstdeliaget (QObject * parent): QItemDelegate (parent) {} void Rich Tekstdeliget :: Paint (Kyupenetr * Painter, Const Kyuesileopshndrishyaitm & amp; Opt-ion, constant qmdale index and index) const {if (option.state & amp; QStyle :: State_Selected) painter- & gt; Warehouse (option. Correct, option.palette.highlight ()); Painter- & gt; Save (); QTextDocument document; Document.setTextWidth (option.rect.width ()); QVariant value = index.data (Qt :: DisplayRole); If (value.isValid () & amp;! Value.isNull ()) {document.setHtml (value.toString ()); Painter- & gt; Translation of (option.rect.topLeft ()); Document.drawContents (painter); } Painter- & gt; resumed (); }
ui-> Table view- & gt; SetItemDelegateForColumn (colIndex, new richtestalegate (ui- & gt; tableView));
model -> Items (Line Indand, Coal Indexes) - & gt; Settext (some richtext);
Comments
Post a Comment