logo
down
shadow

QTreeWidgetItem display html


QTreeWidgetItem display html

Content Index :

QTreeWidgetItem display html
Tag : html , By : user103892
Date : November 24 2020, 05:47 AM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Display HTML As Text, Change BBCode to Display as HTML JQuery/JS


Tag : javascript , By : Doc Immortal
Date : March 29 2020, 07:55 AM
wish of those help Set the target's text() with the full text; so your HTML tags will be encoded. Then do the BBCode replacement on the encoded HTML:
$('#posttextareadisplay').text( $('#textareainput').val() );

var replacebbcode = $('#posttextareadisplay').
  html().
  replace(/(\[((\/?)(b|u|i|s|sub|sup))\])/gi, '<$2>');

$('#posttextareadisplay').html( replacebbcode );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<textarea name="" id="textareainput" cols="30" rows="10">
  [b]bold[/b] &lt;bold>bold&lt;/bold>
</textarea>

<p id="posttextareadisplay"></p>

How to set QTreeWidgetItem as not Editable


Tag : python , By : Trevor Cortez
Date : March 29 2020, 07:55 AM
hope this fix your issue You just have to perform the inverse operation you did as the Qt flags are bitwise.
item.setFlags(item.flags() & ~QtCore.Qt.ItemIsEditable)

How to get QTreeWidgetItem position?


Tag : qt , By : Angelo Giannatos
Date : March 29 2020, 07:55 AM
hope this fix your issue If you have a QTreeWidgetItem * pitem you can use QTreeWidget::visualitemRect...
QRect viewport_relative_rect = pitem->treeWidget()->visualItemRect(pitem);

Parent a QTreeWidgetItem to an existing QTreeWidgetItem to second column maintaining the first column


Tag : python , By : Neuromaster
Date : March 29 2020, 07:55 AM
Hope that helps You could set the check boxes to the second column in your QTreeWidget and swap the first and second sections of the header, e.g.
from PySide2 import QtWidgets, QtCore

class MyItem(QtWidgets.QTreeWidgetItem):
    def __init__(self, label):
        super().__init__([label, ''])
        self.setCheckState(1, QtCore.Qt.Unchecked)
        self.setFlags(self.flags() | QtCore.Qt.ItemIsAutoTristate)

class MyTree(QtWidgets.QTreeWidget):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.setColumnCount(2)
        self.header().swapSections(1,0)
        self.header().resizeSection(1, 80)

if __name__ == "__main__":
    app = QtWidgets.QApplication([])
    tree = MyTree()
    tree.setHeaderLabels(['label', 'checked'])
    items = [MyItem(f'item {i}') for i in range(6)]
    tree.insertTopLevelItems(0, items)
    for i, item in enumerate(items):
        for j in range(4):
            items[i].addChild(MyItem(f'item {i}-{j}'))
    tree.show()
    app.exec_()

QWidget in QTreeWidgetItem disappearing after reordering the QTreeWidgetItem


Tag : cpp , By : kuba53280
Date : March 29 2020, 07:55 AM
this will help Why are widgets deleted?
When the drag and drop is performed, the data of the selected items is coded (roles and associated values) and saved in a QMimeData. When the drop is accepted, the source items are deleted and new items are created with the information stored in the QMimeData, inside the saved information there is no widgets information since this does not have relation with the model. And since the items are deleted, their widgets are also deleted.
#include <QApplication>
#include <QLabel>
#include <QTreeWidget>
#include <QDebug>

static void on_destroyed(){
    qDebug()<<"destroyed";
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QTreeWidget w;
    w.setSelectionMode(QAbstractItemView::SingleSelection);
    w.setDragEnabled(true);
    w.viewport()->setAcceptDrops(true);
    w.setDropIndicatorShown(true);
    w.setDragDropMode(QAbstractItemView::InternalMove);

    for(int i=0; i< 5; i++){
        QTreeWidgetItem *it = new QTreeWidgetItem(&w);
        QLabel *lbl = new QLabel(QString::number(i));
        QObject::connect(lbl, &QObject::destroyed, on_destroyed);
        w.setItemWidget(it, 0, lbl);
    }
    w.show();
    return a.exec();
}
#include <QApplication>
#include <QStandardItemModel>
#include <QTreeView>
#include <QHeaderView>
#include <QDropEvent>
#include <QStyledItemDelegate>
#include <QLineEdit>

class ToolsSelectorDelegate: public QStyledItemDelegate{
public:
    using QStyledItemDelegate::QStyledItemDelegate;
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const{
        QLineEdit *le = new QLineEdit(parent);
        return le;
    }
    void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &) const{
        QRect r(option.rect);
        r.adjust(2, 2, -2, -2);
        editor->setGeometry(r);
    }
};

class ToolsSelectorWidget: public QTreeView{
    QStandardItemModel model;
public:
    ToolsSelectorWidget(QWidget *parent=nullptr): QTreeView(parent){
        setItemDelegate(new ToolsSelectorDelegate(this));
        setModel(&model);
        header()->hide();
        setSelectionMode(QAbstractItemView::SingleSelection);
        setDragEnabled(true);
        viewport()->setAcceptDrops(true);
        setDropIndicatorShown(true);
        setDragDropMode(QAbstractItemView::InternalMove);

        for(int i=0; i<4; ++i) {
            QList<QStandardItem *> items;
            for(const QString & text: {"Preview", "Name", "Visible", "Locked"}){
                QStandardItem *it = new QStandardItem(QString("Part%1 %2").arg(i).arg(text));
                it->setFlags(it->flags() & ~Qt::ItemIsDropEnabled & ~Qt::ItemIsEditable);
                items.append(it);
                if(text == "Visible" || text == "Locked"){
                    it->setFlags(it->flags() | Qt::ItemIsUserCheckable);
                    it->setCheckState(Qt::Unchecked);
                }
                else if (text == "Name") {
                    it->setFlags(it->flags() | Qt::ItemIsEditable);
                }
            }
            for(const QString & children: {"The", "quick", "Brown", "fox", "jump...", "over", "the", "lazy", "dog"})
                items.first()->appendRow(new QStandardItem(children));

            model.invisibleRootItem()->appendRow(items);
            for( int i = 0; i < model.rowCount(); ++i )
                openPersistentEditor(model.index(i, 1));
        }
    }
protected:
    void dropEvent(QDropEvent *event) {
        QModelIndex droppedIndex = indexAt(event->pos());
        if( !droppedIndex.isValid() || droppedIndex.parent().isValid())
            return;
        QTreeView::dropEvent(event);
    }
};

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    ToolsSelectorWidget w;
    w.show();
    return a.exec();
}
Related Posts Related QUESTIONS :
  • CSS background for div element is not working
  • CSS Marquee: multiple paragraphs overlaps
  • I want to align search bar to extreme right
  • Getting blank white space to the left of content inside pre tags
  • My viewer.html won't load any css and jss files
  • How to apply multiple styles to HTML to only part of a title?
  • Want to make text div transparent on a parallax area
  • Is there a way to make this ID plus descendants CSS rule less specific?
  • Is there a way to drop in a stylesheet to get a Material theme or similar for all form elements on the page?
  • How do I make a sideways L look in html/css?
  • Why won't the color #e67d22e1 display in Safari?
  • How to select specific tag's attribute value with xPath?
  • How to make div rows fill available height
  • How to fix text inside a block that grows
  • svg hexagon halftone pattern
  • How to edit a website's element's background colors using a chromium extention
  • What is the main tag in HTML5 ? How does it differ from body tag?
  • My image is flowing out from my div column. How I can fix it and made the image full-size into div
  • How to draw line in react
  • Why Transition css is not working in child selector css
  • How to modify materialize css select option?
  • How to center some text in a rectangle in CSS?
  • How do I equally space out css grid columns?
  • How to make sure all the parts of a macro are running correctly?
  • How to adjust the zoom of website at different browser at different screen size?
  • Can't set max height on child div properly
  • Why background color is not applying to DIV container?
  • Need to select the first-child
  • No space between attributes in buttons
  • How can I block google from crawling my page, but still let Baidu do it?
  • Rendering html content in matToolTip (Angular)
  • Embedding an iframe when iframe height is variable
  • How to use 'word-break: break-word' with link inside of text?
  • How I can animate circular progress bar from left to right?
  • Angular 6 - How can I hide a div onclick of outside of that div
  • How to fill an inline-block div with a solid color?
  • Form file doesn't align with rest of form
  • How to trim off left and right sides of image evenly as I reduce my screen size? (@media query)
  • How can I password protect a section of a static website?
  • Move a div up when I hover over it
  • Why is "align" not a valid attribute of div but still works?
  • Behavior with height/minHeight and display:flex
  • How can i change my h2 title to <p> text while keeping size and alignment?
  • Hover on the text to change size using CSS
  • How to keep a grid of cols without breaking on a new row?
  • Why is bottom: 0 not enough to move ::after content directly below main content?
  • Why does a React build need to be served? Why can't I just open it in the browser?
  • What is the proper way to target the tab key 'highlight' events on an html element?
  • How to Implement dot and line below the text in CSS?
  • DIVs not properly aligned
  • HTML 'for' tag not working for <p> but works on <label>
  • <p> element does not appear to be within parent <footer> element
  • Why flex container is smaller than its content
  • Center an image and a text in a div
  • .class with display: none -> .class:focus with display: block; causes links to not work
  • Best way to use a right pointing arrow in CSS animation
  • Angular 7 : Select tag doesn't display options
  • Orientation: Landscape showing true for desktop
  • How to adjust text in a table
  • React Button Click Event Not Firing - One Button Works, One Button Doesnt
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com