Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.4k Posts
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    18 Views
    No one has replied
  • Inserting text into QTextEdit freezes UI

    Solved
    13
    0 Votes
    13 Posts
    1k Views
    C
    Further reading: Stack Overflow: QTextEdit vs QPlainTextEdit. QPlainTextEdit Documentation: Introduction and Concepts. Differences to QTextEdit.
  • Font sizes too small on MacOS

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    C
    Thanks, I'll find a way to get the default font and then base all my other fonts on it.
  • QT Project on github

    Solved
    5
    0 Votes
    5 Posts
    2k Views
    SGaistS
    You clone it on your other machine and continue your work there. Commit your work regularly and push back to GitHub. When switching machine pull your code changes. I recommend working with topic branches to scope your work.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Why Inherit QWidget cant set background color If use Q_OBJECT In Qt6.5

    Solved
    10
    0 Votes
    10 Posts
    1k Views
    JonBJ
    @JoeCFD I know that. The issue is from the Qt wiki, https://wiki.qt.io/How_to_Change_the_Background_Color_of_QWidget, Using Style Sheet sub-heading: Note: If you subclass a custom widget from QWidget, then in order to use the StyleSheets you need to provide a paintEvent to the custom widget : void CustomWidget::paintEvent(QPaintEvent* event) { QStyleOption opt; opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); QWidget::paintEvent(event); } And (at least I thought) I recall having to do this, recently. I don't know how come the OP does not need same. There you are.
  • Editing items in custom QTableWidget

    Solved
    16
    0 Votes
    16 Posts
    2k Views
    V
    @JonB Thank you so much, that was very helpful. I will look into this issue and try to do as you wrote.
  • Wierd behaviour with takeRow() of QtreeView.

    Unsolved
    4
    0 Votes
    4 Posts
    227 Views
    JonBJ
    @StudentScripter I don't know, you should perhaps put some debugging information in or run under debugger. One thought (only a thought): you are iterating through and moving around items that are currently selected. I would eliminate that, while you test. Get rid of any sorting, get rid of any selection lists. Just start with, say, 1 parent item and its 2 children for the whole of your model/tree. Get that working, ignoring "selections". When that's done move back to selections/sorting/whatever.
  • Signal is not read by the Class

    Solved
    22
    0 Votes
    22 Posts
    2k Views
    V
    @jsulm https://forum.qt.io/post/775285
  • Build worked with QT6.2.4 but failing with QT6.5.3

    Unsolved
    4
    0 Votes
    4 Posts
    385 Views
    S
    Created bug report: https://bugreports.qt.io/browse/QTBUG-118406
  • QString::number(14.24,'g',3) returns 14.3 ?

    Unsolved
    3
    0 Votes
    3 Posts
    2k Views
    Paul ColbyP
    I used QString::number(doubleNumber, 'g' , 3) to get String representing the significant decimals up to 3. The g format doesn't give 3 "significant decimals", it gives 3 "significant digits" - this includes digits both before (excluding leading 0's) and after the decimal. Have a read of https://en.wikipedia.org/wiki/Significant_figures for more info. It works well in 99.9999% cases but for 14.25 instead of giving 14.25 it returns 14.3 14.3 is correct. The three significant digits there are 1, 4, and .3. I know I could use QString::number(doubleNumber'f',3) ... Why is that The reason the f format gives more decimals in your example, is that the f format interprets the precision parameter as a number of decimals, whereas g interprets it as a number of significant digits (which, as I mentioned above, includes digits before the decimal too). This is documented in the table under QLocale::toString(), which QString::number() links to (and @JonB referenced above). See the "Meaining of precision column: [image: 2f1ad327-50d1-40ae-a2f0-d5cf4ca0c35c.png] and what to use instead? If you specifically want "up to 3 decimals", as opposed to "exactly 3 decimals" (f) or "up to 3 significant digits" (g), then I suppose using f then trimming trailing 0 chars is one way to go. Just one of many ways to do it: const double doubleNumber = 14.25; qDebug() << QString::number(doubleNumber,'f',3); qDebug() << QString::number(doubleNumber,'g',3); qDebug() << QString::number(doubleNumber,'f',3).remove(QRegularExpression(QStringLiteral("0+$"))); Outputs: "14.250" "14.3" "14.25" Cheers.
  • Default layout alignment

    Unsolved
    2
    0 Votes
    2 Posts
    236 Views
    C
    @1XU7 Different in what way? You are setting the layout's alignment within its parent. The widgets you put in the layout have their own alignment value.
  • Qt6 Replacement for QMediaPlayer::hasSupport()

    Unsolved qmediaplayer qt5.15.0 qt6.5.0
    3
    0 Votes
    3 Posts
    693 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
    185 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.