What happened to QListViewItem in qt4? - qt

I don't do a lot of Qt programming so this may sound like a silly question, but what happened to QListViewItem in qt4?
I have this application I wrote some time ago in qt3. I changed that to qt4 using the aptly name "qt3toqt4" program (all this on a Fedora platform).
Internally it seems to change a lot of classes from QClass to Q3Class (probably to provide some sort of backwards compatibility) and then compile it with qt4. I had some problems with it today (to do with reading stdout from a QProcess, but that aside) and I decided to simply rewrite the application in qt4.
Now for the problem - I use a QListView and to this I add loads of QListViewItems in a tree like structure. Something like this:
But that doesn't seem to be available anymore in qt4. And I can't find any examples that provide this behaviour either. Is there a way to do this in qt4? To maybe make it more complicated - I used my own QListViewItems (derived from QListViewItem) ...

The widget you are looking for in Qt 4 is QListWidget and its item class QListWidgetItem. It pretty much corresponds to the QListView widget in Qt 3 with a classic item-based interface for adding and removing items. You can subclass QListWidgetItem just as you subclassed QListViewItem in Qt 3.

Just to complete this question. It is QTreeWidget and QTreeWidgetItem that implement this behaviour in qt4.

Related

Treeview for FileSystem with checkboxes in qt

We need a tree view with File system and check boxes in QT. Is there any way to achieve that?
The tree we need would look something like below:
UPDATE:
I am able to achieve it with subclass of QFileSystemModel. Still have few challenges, but at least subclass is working. Below is the code if anyone needs it. Below is the link to the code -
https://drive.google.com/file/d/1qViZ3iEW2pV2th0jQhzneDL14SEhIgS0/view?usp=sharing
The pending work is to apply a wait cursor (or make treeview uneditable when the check/uncheck is taking place).
PS: It will take a lot of time if root node is checked.
Well, all of that can be achieved with minimal customizations of built-in classes, actually those checkboxes is almost the only thing that has to be done yourself.
QFileSystemModel already provides a proper model for displaying the current filesystem contents, it can be subclassed
As for QML, the best demo is already provided by Qt, check the File System Browser Example. This example uses some deprecaded Qt functionality, but still it shows the basic concept.
The modern techniqes can be also found in the answers to the following question: Qt File Browser based on QML
Hopefully, all that helps you, good luck!

Is there any plan to add Qxt features to Qt?

Qxt is an extension library for Qt providing a suite of cross-platform utility classes to add functionality not readily available in Qt. Qxt consists of several modules, each of which lives in a separate library. It has many nice features like:
QSlider with two buttons
Rotating & richtext buttons and labels
LineEdit with sample text
managing many screen settings
String SpinBox
Check ComboBox
Global Shortcut (hot keys)
Schedule View
Tooltip with arbitrary widget on it
RPC(connecting signals and slots through network)
XML-RPC
QxtSQLPackage (Sending SQL query result through network or to a file)
QxtSlotMapper (Map a signal to slots based on parameter value)
Qt comes with lots of new features in each release. I wonder why these useful and nice features are not included in new versions of Qt. Does anybody know if there is any plan to add these features to Qt in the future?
While I do totally understand not just sending Qxt code up stream, because it can be very kludgy, some of the things mentioned are a bit silly as to why they're not included already. The global shortcuts is the number one thing that comes to mind. Having sample text in a line edit would be another cool feature.
For a while now, in my spare time, I've been working on a note taking app, and I've specifically went with QT because of the ease of having it work cross platform compared to GTK or other GUI frameworks. One of the major concepts was having a global hotkey to make the application appear and disappear, but because QT doesn't do this on its own, I had to deal with Qxt for this one function, and it made it a giant mess to get going. I dealt with tons of bugs that prevented me from building versions for Windows. If I could, I'd gladly ditch Qxt in favor of something already baked in to QT.
Qxt grew out of a need for features that QT wouldn't include for one reason or another, and I frankly just don't understand why.

Qt 5.x Custom Widget Creation and Use

I'm returning to Qt programming after an absence of a couple of years, and I'm starting with Qt 5.1. In the past, I've used the designer, and a good deal of hand-crafted code to put Qt projects together. Now, we'd like to make heavy use of the Creator.
But I'm not seeing how to accomplish some seemingly basic tasks. For example, I'd like to design a custom widget, then pull it into my main application, but although the Creator allows me to make multiple files within a project, they seem to have no knowledge of one another as far as the Creator itself is concerned. Once my widget is built, there's no way to pull it into the main application, and also no way to test it independently, at least that I'm able to find.
It seems as though documentation for Qt has taken a major blow somewhere along the line. It is cursory and thin, compared to the extremely detailed docs that used to be available in the past.
If someone can point me to a decent collection of documentation and tutorials, I would be grateful.
Unit Testing
Use the Qt Test module: https://doc.qt.io/qt-5/qttest-index.html
Using Custom Widgets
I'm not 100% sure what you meant by "pull [the widget] into the main application".
If you want to combine your custom widgets in Qt Designer, add a placeholder (blank) QWidget in the parent and Promote it to your custom widget:
https://doc.qt.io/qt-5/designer-using-custom-widgets.html#promoting-widgets
If you want to combine your custom widgets in C++, instantiate your custom child widget and add it into the parent widget's layout using QLayout::addWidget():
https://doc.qt.io/qt-5/qlayout.html#addWidget
If you want to make your application display a custom widget, simply #include the widget's header, instantiate the widget, and call QWidget::show():
https://doc.qt.io/qt-5/qwidget.html#show
If you want to develop your custom widget in a separate standalone project, include it in your main project as a Subproject:
https://doc.qt.io/qtcreator/creator-project-creating.html#adding-subprojects-to-projects
How do I make a subproject with Qt?
Other Notes
Qt Designer has been integrated into Qt Creator for many years. Qt Designer and its documentation have changed very little between Qt 4.8 and Qt 5.
The extremely detailed docs for Qt 5 are at https://doc.qt.io/qt-5/. There are links to useful doc collections in the nav bar on the right.
I recommend exploring QML/Qt Quick. It's much easier to create QML-based GUIs compared to widget-based GUIs. It's still a young technology though, so it might not suit your needs yet: http://doc.qt.io/qt-5/qmlapplications.html

Embedding Qt GUI into existing OpenGL program

I'm currently trying to get Qt working with my existing program.
I'm using SFML for creating my OpenGL rendering context and creating the window. The things I tried out so far however always create a separate window by Qt instead of just rendering into the existing context.
Is there any way I can force Qt to render to an already existing OpenGL context?
I've not looked into the specifics, but this has been done for openage.
I think looking at the documentation for QQuickRenderControl might be a good place to start.
Qt wants full control over the windows and the event loop, so this will not work (unless you put a lot of effort into it). Your best bet is using a QGLWidget and emulate the event management of SFML with that, so that your application effectively runs on Qt. It is very well possible to render Qt widgets into a OpenGL window (Qt has a OpenGL widget backend) but this must be still managed by Qt itself.

VTK rendering from within a QGLWidget

I have a problem that i am trying to sort out for days already, without much success..
So, basically i want to use VTK from Qt, and i know that there is the nice QVTK module for that.
My problem is that i somehow have to do my rendering from within a QGLWidget (i am using a sort of framework where my views are qglwidgets, more or less, and i cannot really use something else than this)
i found resources such as http://prashanthudupa.livejournal.com/48221.html for rendering vtk within a QGraphicsView, but i still cannot find if or how to render a vtkrenderer from within a qglwidget
thanks for any help

Resources