Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.3k Topics 455.8k Posts
  • 0 Votes
    3 Posts
    338 Views
    ademmlerA
    @johngod Thx John I checkt his out but it did not worked. However I found simple a solution: The rendering of Qt is in pixels without any scaling. This means that the scaling factor is (physical screen resolution / divided by image desinty)
  • QRegex help

    Unsolved
    2
    0 Votes
    2 Posts
    168 Views
    C
    @Rua3n By default: The RE dot . does not match newlines A string containing multiple newlines is a single string to the RE Your RE tester is feeding the lines in your test string one at a time. You are feeding the RE all the input as a single string. The RE cannot match because the first newline in the string cannot be consumed by the .* Try: QRegularExpression regex(s, QRegularExpression::MultilineOption); This will not remove lines, but it will remove the text matched leaving a vestigial \n
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • Qt from crontab errors

    Unsolved
    5
    0 Votes
    5 Posts
    554 Views
    C
    I am going to guess that you are trying to create some sort of kiosk machine that automatically launches a UI at system start. If that is what you are after then you should consider: Enable Autologin Use a custom .xsession file to launch your application when X starts. Other ways to address this involve using /etc/inittab (not crontab) to launch a script that starts X and then your kiosk application. This approach can ensure the UI is restarted if it crashes. How this interacts with a systemd-ified environment I cannot say.
  • Make Qt terminal app executable and add it to favorites tab @ Ubuntu

    Unsolved
    5
    0 Votes
    5 Posts
    468 Views
    C
    @JacobNovitsky Right-click where exactly? The right-click menu is generally context sensitive and also populated with actions not applications.
  • How to install Qt 6.4.3 or newer (fresh update) without gui

    Unsolved
    2
    0 Votes
    2 Posts
    832 Views
    SGaistS
    Hi, Here you have the documentation on how to sue the online installer from the command line. Otherwise, there is also the aqinstall project.
  • How to rotate QGraphicsItem right after mouse?

    Solved
    5
    0 Votes
    5 Posts
    639 Views
    johngodJ
    @Valderman I did something like that in a project of mine, but with a difference that the rectangle does not rotate in his center but rotates relative to a center defined in a first click position called commandInitialPos, then you do a second click to start rotating, then you move the mouse to rotate. I am posting the relevant code I used may it can be helpfull for you to adapt the relevant pseudo code and link to the project: https://bitbucket.org/joaodeusmorgado/techdrawstudio/src/142960ab5c809ddcbd20fb40f294e01d85c850d5/qml/qmlEntities/EntityTemplate.qml#lines-117 //first click - define the center of rotation onCommandCprStart: function(pos) { commandInitialPos = pos //assume that pos is the mouse click position } https://bitbucket.org/joaodeusmorgado/techdrawstudio/src/142960ab5c809ddcbd20fb40f294e01d85c850d5/qml/qmlEntities/RectangleThick.qml#lines-39 //second click - start rotation position onCommandCprUpdate: function(pos, ....){ rotateStartPoint = pos //save the start rotation position //calculates and saves the start angle rotateStartAngle = mathLib.angleFromPoints(commandInitialPos, rotateStartPoint) rectP0aux = re.p0 // here I just saving the rectangle initiall position vertexs rectP1aux = re.p1 rectP2aux = re.p2 rectP3aux = re.p3 } https://bitbucket.org/joaodeusmorgado/techdrawstudio/src/142960ab5c809ddcbd20fb40f294e01d85c850d5/qml/qmlEntities/RectangleThick.qml#lines-75 onCommandMtm: function(pos, ....){//this is equivalent to mouse move rotateUpdateAngle = mathLib.angleFromPoints(commandInitialPos, pos) var angle = rotateUpdateAngle - rotateStartAngle // lets do it baby, lets rotate it, yeahhhh, updates the rectangles vertices, which is the rotation re.p0 = mathLib.rotate2DFromPoint(commandInitialPos, angle, rectP0aux) re.p1 = mathLib.rotate2DFromPoint(commandInitialPos, angle, rectP1aux) re.p2 = mathLib.rotate2DFromPoint(commandInitialPos, angle, rectP2aux) re.p3 = mathLib.rotate2DFromPoint(commandInitialPos, angle, rectP3aux) } https://bitbucket.org/joaodeusmorgado/techdrawstudio/src/142960ab5c809ddcbd20fb40f294e01d85c850d5/mathlib.cpp#lines-103 QVector3D MathLib::rotate2DFromPoint(const QVector3D &center, const float &angle, const QVector3D &p) const { float cosAngle = qCos(angle); float sinAngle = qSin(angle); float x = cosAngle*p.x() - sinAngle*p.y() + center.x() - cosAngle*center.x() + sinAngle*center.y(); float y = sinAngle*p.x() + cosAngle*p.y() + center.y() - sinAngle*center.x() - cosAngle*center.y(); return QVector3D(x, y, p.z()); } This is the rectangle rotating: [image: x7eha2y]
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • Is it possible to pop a mainformwidget in and out of a Tab widget?

    Unsolved
    12
    0 Votes
    12 Posts
    1k Views
    V
    @visinet After some more playing with tabifyDockWidget, I got it figured out and working. I just always use the main/first dockwidget as the first parameter and the newly dynamically created dockwidget as the second. When I was originally looking at the tabifyDockWidget function I just wasn't understanding the concept. Thanks again.
  • How to choose a set of plug-in libraries depending on the selected Kit

    Solved
    2
    0 Votes
    2 Posts
    136 Views
    8Observer88
    I found a solution here: Qt .pro file get Qtkit name CONFIG("windows") { INCLUDEPATH += $$PWD/libs/openal-soft-desktop-1.23.1/include LIBS += -L$$PWD/libs/openal-soft-desktop-1.23.1/lib/x64 LIBS += -lOpenAL32.dll } CONFIG("armeabi-v7a") { INCLUDEPATH += $$PWD/libs/openal-soft-android/include contains(ANDROID_TARGET_ARCH, armeabi-v7a) { ANDROID_EXTRA_LIBS += $$PWD/jniLibs/armeabi-v7a/libopenal.so } } CONFIG("x86_64") { INCLUDEPATH += $$PWD/libs/openal-soft-android/include contains(ANDROID_TARGET_ARCH, x86_64) { ANDROID_EXTRA_LIBS += $$PWD/jniLibs/x86_64/libopenal.so } }
  • How to write a data into csv file colmn by column

    Unsolved
    2
    0 Votes
    2 Posts
    187 Views
    JonBJ
    @swapna-v There isn't much to say. Build each line output as comma-separated values from the columns.in a loop. No reason for it to stop at 2 columns, and nobody can say why you say "printing continuously". Your output seems to show you are saving columns as multiple lines. You don't show your produced CSV file, you don't show the code you write.
  • Qopenglbuffer - 64 bit addressing?

    Solved
    7
    0 Votes
    7 Posts
    563 Views
    SGaistS
    AFAIK, most if not all games adapt the level of details based on the zoom factor because there's no sense in calculating all the details of the grass at the limit of the forest located 2km away from you. But it start making sense when you are close to it.
  • Failed to find required Qt component "Core5Compat".

    Unsolved
    2
    0 Votes
    2 Posts
    277 Views
    hskoglundH
    Do you mean this one: [image: c23540ce-d527-463b-b3d9-21a89d2af560.png]
  • Bug in QImage

    Solved
    10
    0 Votes
    10 Posts
    693 Views
    Christian EhrlicherC
    @wostka said in Bug in QImage: Not a bug, a feature... :D No feature but a mandatory thing - otherwise there is no reference to the resource and the lnker can throw it away.
  • Restrict QSslSocket to accept only from defined IP or local host. How?

    Solved
    4
    0 Votes
    4 Posts
    257 Views
    JonBJ
    @bogong The forum topic is from 2010. I don't see anything "6.x" about that or concerning a signal, but never mind, it's the right thing to use.
  • Scroll Bar diretion for RTL languarges

    Unsolved
    9
    0 Votes
    9 Posts
    790 Views
    Christian EhrlicherC
    @Volker-D said in Scroll Bar diretion for RTL languarges: Thank you! It was pure luck this time - the reason was easy to find :) I'll take a look into the other one if I find some time.
  • Can I open Qt project with Ubuntu cmd

    Solved
    2
    0 Votes
    2 Posts
    126 Views
    C
    @JacobNovitsky # System Qt Creator qtcreator workspace/simple_example/simple_example.pro # Local Qt installed by online installer ~/Qt/Tools/QtCreator/bin/qtcreator workspace/simple_example/simple_example.pro Adjust the paths to suit.
  • qt call ocx

    Unsolved
    8
    0 Votes
    8 Posts
    547 Views
    X
    @JonB Thanks. I'm going to try the queryInterface() function.
  • valgrind in qtcreator crashed

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    s_milena__97S
    @Zekses Thank you. Really helpful! ❤️ It saved me for my software verification student project!
  • 0 Votes
    3 Posts
    512 Views
    Y
    Remove space; Inside the table cell but outside my custom widget Here some code snap. @ChrisW67 #include "ElementsListWidget.h" #include "AbstractElement.h" #include "ElementDragEventHandler.h" #include <QAbstractScrollArea> #include <QGridLayout> #include <QLabel> #include <QPixmap> #include <QScrollArea> #include <QSortFilterProxyModel> #include <QVariant> #include <qscrollbar.h> #include <qstandarditemmodel.h> #include <qtreeview.h> ElementsListWidget::ElementsListWidget(QWidget* parent) : QWidget(parent) { QVBoxLayout* mainlayout = new QVBoxLayout(this); mainlayout->setContentsMargins(0, 0, 0, 0); elementsListLayout = new QTreeView(this); elementsListLayout->setContentsMargins(0, 0, 0, 0); elementsListLayout->setHeaderHidden(true); elementsListLayout->setIndentation(0); elementsListLayout->setUniformRowHeights(false); elementsListLayout->setObjectName("ElementsListWidget"); elementsListLayout->setSelectionMode(QAbstractItemView::NoSelection); elementsListLayout->verticalScrollBar()->parent()->setProperty("background_transparent", true); elementsListLayout->horizontalScrollBar()->parent()->setProperty("background_transparent", true); sourceModel = new QStandardItemModel(this); elementsListLayout->setModel(sourceModel); mainlayout->addWidget(elementsListLayout); setLayout(mainlayout); elementsPerRow = 3; totalModelElements = 0; sourceModel->setColumnCount(elementsPerRow); } void ElementsListWidget::addElement(AbstractElement* element) { elementsModel << element; showWidgetOnView(createDisplayUnit(element)); } QWidget* ElementsListWidget::createDisplayUnit(AbstractElement* element) { if (!element) { return nullptr; } QWidget* elementDispalyWidget = new QWidget; elementDispalyWidget->setObjectName("elementDisplayUnit"); QVBoxLayout* elementdisplayLay = new QVBoxLayout(elementDispalyWidget); //elementdisplayLay->setContentsMargins(0, 0, 0, 0); QLabel* elementIconLabel = new QLabel(elementDispalyWidget); elementIconLabel->setObjectName("elementIconLabel"); elementIconLabel->setProperty("element", QVariant::fromValue(static_cast<AbstractElement*>(element))); elementIconLabel->setCursor(Qt::OpenHandCursor); elementIconLabel->setAlignment(Qt::AlignCenter); elementIconLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); elementIconLabel->installEventFilter(new ElementDragEventHandler(elementIconLabel)); // Install event filter elementIconLabel->setPixmap(element->getImage().scaled(50, 50)); QLabel* elementNameLabel = new QLabel(element->getName(), elementDispalyWidget); elementNameLabel->setObjectName("elementNameLabel"); elementNameLabel->setAlignment(Qt::AlignCenter); elementNameLabel->setWordWrap(true); elementdisplayLay->setAlignment(Qt::AlignHCenter); elementdisplayLay->addWidget(elementIconLabel); elementdisplayLay->addWidget(elementNameLabel); elementdisplayLay->addStretch(); elementDispalyWidget->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); return elementDispalyWidget; } void ElementsListWidget::setElementsPerRow(int numberOfelementsPerRow) { if (numberOfelementsPerRow > 0) { elementsPerRow = numberOfelementsPerRow; } } void ElementsListWidget::serachElement(const QString& searchText) { clearModel(); // Iterate through the stored widgets in elementWidgetModel for (AbstractElement* element : elementsModel) { if (element && element->getName().contains(searchText, Qt::CaseInsensitive)) { showWidgetOnView(createDisplayUnit(element)); } } } void ElementsListWidget::showWidgetOnView(QWidget* elementDisplayUnit) { if (elementDisplayUnit == nullptr) { return; } QStandardItem* item = new QStandardItem; // Calculate the row and column count for the new element int row = totalModelElements / elementsPerRow; int column = totalModelElements % elementsPerRow; sourceModel->setItem(row, column, item); elementsListLayout->setIndexWidget(item->index(), elementDisplayUnit); totalModelElements++; } void ElementsListWidget::clearModel() { sourceModel->clear(); totalModelElements = 0; } styel sheet for few widget QWidget#ElementsListWidget { background-color: #DAE0E9; color: #3B5571; border: none; } #elementDisplayUnit { background-color: transparent; font-size: 14px; } #elementIconLabel { width: 64px; background-color: #ffffff; border: 1px solid #BEC9CD; height: 64px; position: relative; /* align-items: center; */ border-radius: 5px; /* justify-content: center; */ background-color: #FFFFFF; } #elementIconLabel:hover { background-color: lightgray; } #elementNameLabel { padding: 0px 0 0 0; font-size: 11px; max-width: 64px; text-align: center; line-height: 12px; /* text-overflow: ellipsis; */ background-color: transparent; /* word-wrap: break-word; */ font-weight: bold; }