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

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

Related

QT Arbitrary View Widget

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

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.

Qt: How to create a setting window like in GTK

In Qt 4.8 I want to create a window that looks like the following.
please note that my main concern is the tab-like behaviour of left-side icon+text combination.
The question is what would you recommend me to achieve that look? A QListWidget or a customized QTabWidget?
thanks
Qt Creator - which is written in Qt - has a settings page which might just be what you want:
I would look into the source code of that at http://qt.gitorious.org/qt-creator/qt-creator/trees/master
[Edit]
Found the relevant class here:
https://github.com/qt-creator/qt-creator/tree/master/src/plugins/coreplugin/dialogs
It is the class SettingsDialog. The GUI is setup in createGUI, they are not using an UI file actually.
This class is using a QListView on the left-hand side and a QStackedLayout with several QTabWidgets inside it on the right-hand side
I'd go with a QListWidget on the left connected to a QStackedWidget on the right.
Items in a QListWidget(View) can have icons on their left, selection can be exclusive (single selection) and when clicked emit signals which can change the current widget shown in the QStackedWidget.

Using layout of QMenuBar

Is it possible to get layout from QMenuBar object and add items to it. What I am trying to do is a menu bar containing custom widgets (a clock and login/off widget) on the right.
This code crashes.
QPushButton *b1 = new QPushButton("Button",ui->menuBar);
QHBoxLayout *rlayout = new QHBoxLayout(this);
ui->menuBar->layout()->addItem(rlayout);
rlayout->addWidget(b1);
b1->show();
Is there any other way?
Best regards,
Valentin Heinitz
Would it be possible to create your own container widget, put the menu bar in on the left, and the other widgets in on the right? That should get you similar functionality and appearance to the Qt3 version of the menu bar.
You should look into QWidgetAction, that allows you to insert custom widget in a menubar. You would then have to call QMenuBar::addAction(QAction*) to put your QWidgetAction in the menubar.
I know that it is not part of your question, but maybe QDockWidget would do a better job for what you need??
Hope this helps.

QListView how to add column?

How can I add columns to QListView control. Found a method addColumn while seardhing, but in my Qt Creator 1.2.1 based on Qt 4.5.2(32 bit) QListView doesn't have such method at all !!!
So how would I add columns ?
Say I have 3 columns then what is the code to add a row ?
You can use QTableView for this purpose. But if you need QListView look & feel, you can use QTableView borderless using Qt Stylesheet. Also you may want to add an icon. You can add icons to your QTableView by setting icon data to Qt::DecorationRole.
You cannot add a column, cause list views are designed to view simple lists. You need QTable[View/Widget].
QListWidget is a single column only. Use QTreeWidget/View for multiple columns.
As the start point you could watch how works QTableView class here: http://qt.nokia.com/doc/4.2/sql-tablemodel.html and do the similar things with QListView. So, you can't just emit addColumn() for QListView class, first you need to create model and then do listView->setModel(model).

Resources