QT Arbitrary View Widget - qt

plz click here to show the image
I want to create a set of UI like this.
I don't have source code, but I knew it's done by QT.
So I guess, overall, this is QTreeView
but how is its ChildWidget done?
All the child are different,
There are QCheckBox,
There are QLabel + QLineEdit
There are QTreeView too.
So I want to know how the child widgets are created and inserted to the QTreeView?
Thank you!

http://doc.qt.io/qt-5/modelview.html
ChildWidget are created by delegate. You can read more about delegate in Qt Model/View architecture

Related

Qt Combo box with Check able not working

I have created a QCombobox with checkable items in Qt according to this link. But it works only when i apply QPlastiqueStyle .This style does not work in QT5. What should i do to solve this problem?
The way that I found to solve this problem was to create a custom Widget using QListWidget and QButtons and then promoting my QCombobox to the Custom widget.

Use Model/View on a QListWidget

Yes, you are right. We have QListView already, it is prefect when we are trying to display simple list with Model/View.
But, QListView has lots of problem when we need to display complex list with rich text and widgets. Just think about a timeline-listview for Facebook or Twitter.
Sure, we can implement our own delegate for rich text or images, but ListView can print static item only. So, there isn't a way to show clickable hyperlink (you can calculate position of the mouse and hyperlink, but it is a really drity work) or load asynchronous images.
Well, QListWidget seems our solution. We can put widgets into it. But. we will lost our Model/View/Delegate architecture, that is terrible!
Now, my solution is writing my listview in QML. Other widget are still native Qt widget. (I don't like a non-native pure QML user interface.)
QML is really flexiable when doing that kind of work. Then export my model, finally put a viewer into my QMainWindow. But coding in two programming languages and trying to communicate with other native widget is really difficult.
So, is there a way to use Qt's Model/View architecture with QListWidget? Or I have to implement them by myself?
QListWidget does use Qt's MVC, as it derives from QListView and...
QListWidget uses an internal model to manage each QListWidgetItem in
the list.
Just use QListWidget::model () const to access the model.

QWidget stays within parent QWidget

i'm quite new to Qt and i've a question.
I've got an application with multiple windows/QFrame. I'd like them to only exist within the mainwindow (it's also the parent gadget). When I move them, I want the to stay within the parent gadget.
Is is possible ?
If yes, how ?
I've been through the Qt doc and i've found nothing. I though maybe a simple option can do that. Or do I have to create a new Widget with customs mouse Event methods ?
Thx
If you want a Multiple Document Interface (MDI) GUI you can use the QMdiArea and QMdiSubWindow classes to implement this. Have a look at the detailed description section of QMdiArea for using it with a QMainWindow example, but it also works on any other widget as well.

How to customize a listview in Qt

I want to customize a listview in Qt, can anyone provide me some example or hints of how to do it? I am new to Qt.
You can apply stylesheet to your QListView.
Check out here for the Qt documentation of customizing QListView using stylesheets.
If you're using a standard item model or a QListWidget (or any other model that uses QStandardItem), you can set appearance properties on the items using setData.
So, The following will add a red item to a list widget:
QListWidgetItem *colorItem = new QListWidgetItem("Red");
colorItem->setData(QBrush(QColor(Qt::red)), Qt::ForegroundRole);
list.addItem(colorItem);
For a working code example and more detailed explanation, please see: http://ynonperek.com/qt-mvc-customize-items

how to drag and drop from another widget on to a QGraphicsScene

I need to drag from a QListWidget or something similar and drop on a QGraphicsScene, and create a subclass of QGraphicsItem at the drop location. Anyone have any ideas? I'm using Qt 4.6.3.
The Drag and Drop Puzzle example seems to do what you are looking for: https://doc.qt.io/archives/4.6/draganddrop-puzzle.html

Resources