Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.5k Posts
  • Reporting inappropriate content on the forums

    Pinned Locked spam
    29
    4 Votes
    29 Posts
    35k Views
    A
    Thank you for the report. I have banned the user, which got rid of the spam posting. Not a loss, as this user did not post any other content on the site. Just deleting this one posting was not possible. Thanks for reporting this.
  • Layout of fixed size objects and one object that changes size

    Unsolved qframe qlineedit
    1
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • Issue with QLabel and wordwrap

    Solved
    20
    0 Votes
    20 Posts
    278 Views
    PLL3P
    Hi, closing this thread. To sum up, my issue stems from a Qt layout limitation, for posterity's sake here's the solution that I ended up using to get around my problem: I installed an eventFilter on my QLabel, filtering for QSinglePointEvent and checking wether the cursor was within the text, here's a small code example: bool SubWidget::eventFilter(QObject * iObject, QEvent* iEvent){ if ((iObject == _label) && (iEvent->isSinglePointEvent())){ //if event is a mouse event on _label QFontMetrics fm(_label->font()); int textWidth = fm.horizontalAdvance(_label->text()); // width of the text in pixels int textHeight = fm.height(); // height of the text in pixels int textX = 0; int textY = 0; // calculate the coordinates for the top-left pixel of the actual text, text position depends on alignment if ((_label->alignment() & Qt::AlignLeft) == Qt::AlignLeft){ textX = _label->x(); } else if ((_label->alignment() & Qt::AlignHCenter) == Qt::AlignHCenter){ textX = _label->x() + (_label->width() - textWidth)/2; } else if ((_label->alignment() & Qt::AlignRight) == Qt::AlignRight){ textX = _label->x() + _label->width() - textWidth; } if ((_label->alignment() & Qt::AlignTop) == Qt::AlignTop){ textY = _label->y(); } else if ((_label->alignment() & Qt::AlignVCenter) == Qt::AlignVCenter){ textY = _label->y() + (_label->height() - textHeight)/2; } else if ((_label->alignment() & Qt::AlignBottom) == Qt::AlignBottom){ textY = _label->y() + _label->height() - textHeight; } QSinglePointEvent* pointEvent = static_cast<QSinglePointEvent*>(iEvent); QPointF mousePos = pointEvent->position(); // Get mouse position relative to the label from the event if ((textX <= mousePos.x() && mousePos.x() <= (textX + textWidth)) // if mouse is located within the text area && (textY <= mousePos.y() && mousePos.y() <= (textY + textHeight))) { //Do stuff here to further refine the event //eg: hover event, mousepress event etc etc return true; } else { return false; } } return QWidget::eventFilter(iObject, iEvent); }
  • QWidget not resizing because of Q3DScatter

    5
    0 Votes
    5 Posts
    64 Views
    J
    I undestand. I have updated the code in the original post. I will keep this in mind next time.
  • Laying out items/widgets without stretching/spacing

    Unsolved
    7
    0 Votes
    7 Posts
    81 Views
    JonBJ
    @J.Hilk said in Laying out items/widgets without stretching/spacing: I think if you provide max or fixed sizes, normal layouts work that way? I don't think so (but I will play with it again shortly). Not that I should have to or want either max or fixed sizes on widgets. When you do nothing special on the widgets a horizontal layout spreads them evenly across with "gaps" between each to achieve full justification from left to right, without changing the width of each one. I just want it not to do the "spread out" work and just place them left to right with no extra work. Simplez ;-)
  • Problem with transparent background using Inkscape SVG icons in Qt

    Unsolved
    2
    0 Votes
    2 Posts
    21 Views
    jsulmJ
    @buhtz You can see here what is supported by Qt: https://doc.qt.io/qt-6/svgextensions.html
  • class "has not been declared" in moc file though in class include is correct.

    Unsolved
    13
    0 Votes
    13 Posts
    281 Views
    L
    Thanks for your interest. They are there https://forum.qt.io/topic/163508/headers-not-found/4 Unfortunately, after solving these problems the same type of issue reappeared. ChatGPT pretends that this is because file name should be capitalised exactly the same as the class name which I find hard to believe. For now I am trying another way with the old .pro file.
  • Using QtCharts in a Pyside6 Application

    Unsolved
    2
    0 Votes
    2 Posts
    85 Views
    C
    I am seeing the exact same problem. However, I let AI generate some QML Chart code and the application works. It would be nice to have code completion working.
  • Swapping columns on QTreeView causes row highlight to disconnect

    Solved
    3
    0 Votes
    3 Posts
    50 Views
    P
    @Christian-Ehrlicher Thanks for your response. I was worried that might be the case. Changing the model or implementing a proxy model will be a bigger change to the code, but should be doable.
  • QIcon::pixmap() returns image double the size requested

    Unsolved
    7
    0 Votes
    7 Posts
    700 Views
    J
    i've bypassed it using : QSize iconSize(16, 16); QPixmap img = QIcon::fromTheme("folder-alt").pixmap(iconSize).scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); qDebug() << img;
  • partially update default stylesheet

    Unsolved
    26
    0 Votes
    26 Posts
    742 Views
    SGaistS
    @SimonSchroeder Native styles are implemented such that they follow the original platform style and are thus free to ignore modified palette values to stay coherent. Thus, depending on what you want to change, you will need to check what the original style does underneath. I am not claiming that it's simple for everything, far from it. Many times, it's a question of re-implementing drawPrimitive to either call the base class implementation with modified values or having your own implementation based out of the original class.
  • getting the issues with QDialog

    Unsolved
    5
    0 Votes
    5 Posts
    61 Views
    S
    This is my dialog — when it’s created, a faint shadow briefly appears on the left margin for a fraction of a second. It doesn’t happen every time, but it occurs occasionally
  • Weird behavior of QT windows on Linux

    Solved
    13
    0 Votes
    13 Posts
    248 Views
    deisikD
    The solution was to make the main window stay on bottom with the Qt::WindowStaysOnBottomHint flag set (yes, I can live with that) But if you have other ideas, please share
  • Headers not found

    Unsolved
    4
    0 Votes
    4 Posts
    69 Views
    L
    Seems to be solved by set(CMAKE_INCLUDE_CURRENT_DIR ON) but not quite sure (I have other errors). Why the ui compiler would include with < and < instead of " " ?
  • Terminal Output Of Application Outside of Creator

    Solved
    5
    0 Votes
    5 Posts
    136 Views
    D
    @JonB Thank you for your post. It turns out the AllocConsole() was the solution. It was a Windows problem I was unfamiliar with rather than QT. Have a great week!
  • Qt 6.10 and text encodings

    Unsolved
    16
    0 Votes
    16 Posts
    563 Views
    AndyBriceA
    @cristian-adam Thanks.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • Embedding Lightweight Web Tools into Qt Desktop Apps — Best Approaches?

    Unsolved
    3
    0 Votes
    3 Posts
    120 Views
    A
    Please choose webview2, which has higher performance than QWebEngine and is easier to integrate than cef. refer to https://thinkinginqt.com/20250726_qt-web/20250726_qt-web.html
  • Can't seem to get shaders to work.

    Unsolved
    1
    0 Votes
    1 Posts
    28 Views
    No one has replied
  • Custom QHeaderView doesn't adjust size

    Unsolved
    4
    0 Votes
    4 Posts
    111 Views
    SGaistS
    If you want to sort, why are you setSortIndicatorShown(false); ?