Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.4k Posts
  • Qt6 Replacement for QMediaPlayer::hasSupport()

    Unsolved qmediaplayer qt5.15.0 qt6.5.0
    3
    0 Votes
    3 Posts
    700 Views
    SGaistS
    Hi, To add to @KH-219Design, since 6.5, the default backend has been set to ffmpeg.
  • QTreeView Remove and Re-Insert childitem from parent?

    Unsolved
    18
    0 Votes
    18 Posts
    1k Views
    S
    @Christian-Ehrlicher So i got this working pretty great, but somehow when i move 2 items at ones out of it's parent only the data of one item gets copied over to both new inserted items: This i the start situation (1 parent with 2 child items): [image: 7af7df79-973a-4e1d-ae2a-a21aebd2be91.png] Than i select both items and drop than onto their parent item: [image: 0b7bbbd0-3700-4b67-9d56-b3ea8d06d023.png] After dropping i get two items named identically, but instead they should keep their data: [image: 8fe0b267-976b-43d6-81e0-7d0c679fa1ad.png] Here is my code: void ViewLayerList::dragEnterEvent(QDragEnterEvent *event) { // Ermitteln Sie den Index des Items unter der Maus QModelIndex index = indexAt(event->position().toPoint()); if (!index.isValid()) { // Wenn kein gültiges Item unter der Maus ist, rufen Sie die Basisklasse-Methode auf und kehren Sie zurück QTreeView::dragEnterEvent(event); return; } // Zugriff auf das Modell QStandardItemModel *modelObj = dynamic_cast<QStandardItemModel*>(model); // Überprüfen Sie, ob das Modell korrekt gecastet wurde if (modelObj) { // Vor jedem Drag-Event leeren Sie die Parent-Index-Liste parentChildMap.clear(); selectedIndexList.clear(); // Sammeln Sie die Parent-Indizes für ausgewählte Items QModelIndexList selectedIndexes = selectionModel()->selectedIndexes(); for (const QModelIndex& selectedIndex : selectedIndexes) { QModelIndex parentIndex = selectedIndex.parent(); // Fügen Sie das Paar zur Map hinzu parentChildMap.insert(selectedIndex, parentIndex); // Fügen Sie den ausgewählten Index zur Liste hinzu selectedIndexList.append(selectedIndex); // Zugriff auf das ausgewählte Element und fügen Sie es zur Liste hinzu QStandardItem* selectedItem = modelObj->itemFromIndex(selectedIndex); } int selectedItemCount = selectedIndexes.count(); qDebug() << "Anzahl der ausgewählten Items: " << selectedItemCount; // Nachdem Sie die Map gefüllt haben... for(auto it = parentChildMap.constBegin(); it != parentChildMap.constEnd(); ++it) { qDebug() << "Child: " << it.key().data() << ", Parent: " << it.value().data(); } } QTreeView::dragEnterEvent(event); } void ViewLayerList::dropEvent(QDropEvent *event) { // Ermitteln Sie den Index des Items unter der Maus QModelIndex index = indexAt(event->position().toPoint()); if (!index.isValid()) { QTreeView::dropEvent(event); return; } QModelIndex destinationIndex = indexAt(event->position().toPoint()); // Rufen Sie die Basisklasse-Methode auf, um die Standard-Verarbeitung fortzusetzen QTreeView::dropEvent(event); // Zugriff auf das Modell QStandardItemModel *modelObj = dynamic_cast<QStandardItemModel*>(this->model); // Überprüfen Sie, ob das Modell korrekt gecastet wurde if(modelObj) { qDebug() << "destinationIndex data: " << destinationIndex.data(); // Überprüfen Sie, ob der Zielindex das Wurzelelement als Elternteil hat bool isDestinationRoot = (destinationIndex.parent() == QModelIndex()); qDebug() << "DestinationHasROOT as parent: " << isDestinationRoot; // Nachdem Sie das Ereignis verarbeitet haben... for (const QModelIndex& selectedIndex : selectedIndexList) { // Holen Sie sich den Elternindex für das ausgewählte Element QModelIndex parentIndex = parentChildMap.value(selectedIndex); // Zugriff auf das Elternelement QStandardItem* parentItem = modelObj->itemFromIndex(parentIndex); // Vergleichen Sie die Daten des Elternindex mit den Daten des Zielindex if(parentIndex.data() == destinationIndex.data() && isDestinationRoot) { // Entfernen Sie das Kind-Element aus seinem Elternelement int row = 0; QList<QStandardItem*> items = parentItem->takeRow(row); //THIS COMMET BEHAVES REALLY STRANGE WHEN I REMOVE IT //SEE THE PICTURE BELOW qDebug() << "ItemList:" << parentItem->takeRow(row); // Bestimmen Sie die Position, an die das Element verschoben werden soll int newPosition = parentIndex.row() + 1; // Fügen Sie das Kind-Element an der neuen Position zum invisibleRootItem hinzu modelObj->invisibleRootItem()->insertRow(newPosition, items); } } } } There also is this one comment, everytime i try to remove it,my items get only copied in the dragging process but not removed anymore, so i end up with copies like this: (if the comment is there everything works fine, i found that strange) [image: bb1f24a2-433c-49f4-974b-9a6a90c802a1.png] I only commented out the comment: //qDebug() << "ItemList:" << parentItem->takeRow(row);
  • Memory leak in libQt5Core.so.5.15.7

    Unsolved
    5
    0 Votes
    5 Posts
    448 Views
    jsulmJ
    @chandrakant2023 https://lists.qt-project.org/listinfo/development
  • AUDIOSES.DLL errors on MinGW, but not on MSVC

    Unsolved
    1
    0 Votes
    1 Posts
    474 Views
    No one has replied
  • 0 Votes
    1 Posts
    186 Views
    No one has replied
  • Mouse position issue

    Solved
    3
    0 Votes
    3 Posts
    329 Views
    PerdrixP
    @sierdzio I changed the if statement to read: if (!underMouse() || !displayRect.contains(mouseLocation)) return; and added an update() call to the leaveEvent() handler. Problem solved.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Qt 6.6 Captures images or Video to file crash the application

    Unsolved
    2
    0 Votes
    2 Posts
    186 Views
    jsulmJ
    @Ahimson2 First thing to do if your app is crashing: run through debugger and see where exactly it crashes. You can also post stack trace after crash here. Else we cannot do more than guessing.
  • how to zip and unzip in QT

    Unsolved
    3
    0 Votes
    3 Posts
    2k Views
    jsulmJ
    @jgxy1123 See https://forum.qt.io/topic/74306/how-to-manage-zip-file
  • Sqlite Multithread

    Unsolved
    6
    0 Votes
    6 Posts
    904 Views
    piervalliP
    @KenAppleby-0 In the documentations of Qt https://doc.qt.io/qt-5/sql-driver.html#qsqlite SQLite has some restrictions regarding multiple users and multiple transactions. If you try to read/write on a resource from different transactions, your application might freeze until one transaction commits or rolls back. The Qt SQLite driver will retry to write to a locked resource until it runs into a timeout (see QSQLITE_BUSY_TIMEOUT at QSqlDatabase::setConnectOptions()). In the Sqlite documentation https://www.sqlite.org/c3ref/c_config_covering_index_scan.html#sqliteconfigserialized SQLITE_CONFIG_SERIALIZED There are no arguments to this option. This option sets the threading mode to Serialized. In other words, this option enables all mutexes including the recursive mutexes on database connection and prepared statement objects. In this mode (which is the default when SQLite is compiled with SQLITE_THREADSAFE=1) Final considerations Sqlite is builded with flag THREADSAFE=1 we can check with the query "PRAGMA compile_options;", all mutex are enabled and for default configuration thread mode is SQLITE_CONFIG_SERIALIZED. Until the timeout Sqlite retry to write. For my case I changed to timeout to 5 minute i haved limited the transaction to strictly necessary, because the transaction locks all. In addition PRAGMA journal_mode=WAL; is useful for multithreading. The global QMutex is not necessary.
  • In MAC Send/Write audio data on partcular output channel of audio device

    Unsolved
    7
    0 Votes
    7 Posts
    579 Views
    SGaistS
    I think you have a use case that shows the limit of the current implementation. You should open a bug report to explain your situation and issue.
  • Trying to set the colour for hyperlinks in QTextBrowser

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    Gojir4G
    @Perdrix Sorry to come later on this. But there is an interesting note about this in documentation of QPalette: Note that we do not use the Link and LinkVisited roles when rendering rich text in Qt, and that we recommend that you use CSS and the QTextDocument::setDefaultStyleSheet() function to alter the appearance of links. For example: QTextBrowser browser; QColor linkColor(Qt::red); QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name()); browser.document()->setDefaultStyleSheet(sheet);
  • Qt and coroutines

    Unsolved
    13
    0 Votes
    13 Posts
    2k Views
    F
    Thank you for all your support guys! Everything is much more clear now!
  • QListWidget, new selections, last selections

    Solved
    3
    0 Votes
    3 Posts
    190 Views
    SPlattenS
    @jsulm , thank you, thats what I'm looking at implementing now.
  • QTextStream question

    Solved
    16
    0 Votes
    16 Posts
    2k Views
    Q
    @JoeCFD said in QTextStream question: std::cout << qPrintable( QString( "%1." ).arg( a, 2, 10, QChar( '0' ) ) ) << qPrintable( QString( "%1" ).arg( b, 2, 10, QChar( '0' ) ) ) << std::endl; Compare your statement with mine if I define a simple macro: #define co(width, what) qSetPadChar('0') << qSetFieldWidth(width) << what << qSetFieldWidth(0) Then: "01.02" output is much simpler: cout << co(2,a) << co(0,'.') <<co(2, b) << Qt::endl;
  • windeployqt: Unable to locate ICU library icudt72.dll

    Unsolved
    1
    0 Votes
    1 Posts
    331 Views
    No one has replied
  • How to quit Application immedialy after QMessageBox?

    Unsolved
    5
    0 Votes
    5 Posts
    319 Views
    K
    @Chris-Kawa Nice tipps, thx, I just began this way, forgot to put QApplication to first line
  • 0 Votes
    3 Posts
    192 Views
    D
    @mpergand I will try this, thank you. Update: Works fine, I was unware of sender() of QObject. Thanks!
  • debug.log file created when removing files from qtwebengine_locales

    Unsolved
    1
    0 Votes
    1 Posts
    191 Views
    No one has replied
  • Will Qt support Apple Vision Pro / visionOS?

    Unsolved
    6
    0 Votes
    6 Posts
    854 Views
    SGaistS
    @Felix-van-de-Donk the thread is here.