Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.3k Posts
  • 0 Votes
    6 Posts
    2k Views
    JonBJ
    @CJha That is great. I might be forgetting, but I don't think ~ or # are actually regular expression special characters. However, the escape() method may replace every punctuation character with \-character (including non-ASCII characters like copyright) because that never does any harm/is allowed on any punctuation character. Or it might be enough to let * go to \* and then revert any \*s to plain *s (actually .* in your case).
  • How can I include multiple classes together?

    Solved
    5
    0 Votes
    5 Posts
    257 Views
    yy_pc_programmerY
    @JonB I understood properly now. Thank you for your valuable answers. Have a nice day
  • QTableWidget in QGraphicsScene

    Solved
    5
    0 Votes
    5 Posts
    452 Views
    L
    @LiuXiaoHhan i figureout try this one in middlebtn pressing event setInteractive(false); and after releasing restore this status in QGraphicsView setInteractive(true);
  • Need to identify when all three channels have waveform peaks at the same time

    Unsolved
    1
    0 Votes
    1 Posts
    113 Views
    No one has replied
  • QScreenCapture with partial screen

    Solved
    7
    0 Votes
    7 Posts
    454 Views
    JoeCFDJ
    @Timmy you may rely more on FFMpeg than on QMultiMedia. QMultiMedia is a very basic tool for now. I do not use it at all.
  • "New Class Form" does not name a type

    Unsolved
    16
    0 Votes
    16 Posts
    586 Views
    JonBJ
    @Andrew23 That's like I said then! It has indeed found the function named UpdateWindow() in winuser.h, a Windows SDK header file. And it tells you that is hiding the class UpdateWindow you want it to pick up. You can wait for some C++ guru to suggest your best move. But one thing would work: completely delete your UpdateWindow class and pick some other name for it! Make sure you rebuild from scratch when you do so. Oh, for this error it tells you what you can do here: class UpdateWindow *updateWindow = nullptr; It even says you can click the message to make it do it for you.... I don't know if there will be other similar issues elsewhere, you will always have to use class UpdateWindow ..., might be simpler to rename your class.
  • rendering text in QOpenGLWidget

    Unsolved
    7
    0 Votes
    7 Posts
    8k Views
    P
    I had this issue when I needed to draw axis and corresponding ticks. In Qt4, I can use the following code: for (int i = _Ymin; i <= _Ymax; i = i + _yGrid) { double yPos = (_Ymax-i)*_yscaleF*_yscalingF; double xPos = -_xmin*_xscaleF-_shiftX; if(yPos < (_Ymax-_Ymin)*_yscaleF-_shiftY+1) { glBegin(GL_LINES); glVertex2f(xPos-2, yPos); glVertex2f(xPos+2, yPos); glEnd(); renderText (xPos - offset,yPos+5 , 0, QString::number(i/10.0)); } } glScalef(_xscalingF,_yscalingF,0); However, when I try to migrate my code to Qt6, there's no renderText anymore. After searching on the web and investigating the source code of renderText, finally I found the solution, one needs to save/load gl status: glBegin(GL_LINES); glVertex2f(xPos-4, yPos); glVertex2f(xPos+4, yPos); glEnd(); qt_save_gl_state(); renderText(xPos - offset,yPos+5 , QString::number(i/10.0)); qt_restore_gl_state(); Here are the def of qt_save_gl_state, renderText, qt_restore_gl_state: static void qt_save_gl_state() { glPushClientAttrib(GL_CLIENT_ALL_ATTRIB_BITS); glPushAttrib(GL_ALL_ATTRIB_BITS); glMatrixMode(GL_TEXTURE); glPushMatrix(); glLoadIdentity(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glShadeModel(GL_FLAT); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_STENCIL_TEST); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); } static void qt_restore_gl_state() { glMatrixMode(GL_TEXTURE); glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glPopAttrib(); glPopClientAttrib(); } void GLWidgetnew::renderText(double x, double y, const QString text) { GLdouble textPosX = x, textPosY = y; // Retrieve last OpenGL color to use as a font color GLdouble glColor[4]; glGetDoublev(GL_CURRENT_COLOR, glColor); QColor fontColor = QColor(glColor[0]*255, glColor[1]*255, glColor[2]*255, glColor[3]*255); // Render text QPainter painter(this); painter.translate(float(_shiftX),float(_shiftY)); //This is for my own mouse event (scaling) painter.setPen(fontColor); QFont f; f.setPixelSize(10); painter.setFont(f); painter.drawText(textPosX, textPosY, text); painter.end(); } Note that one might need to adjust the renderText function for some special purposes (e.g., scaling, translation etc) src code of the project can be found here QtSignalProcessing
  • Qt Build Issue

    Unsolved
    8
    0 Votes
    8 Posts
    963 Views
    S
    I am able to run my app through code. Thank you so much All. Special thanks to @Christian-Ehrlicher. Great help!.
  • Qt (maybe 5) became sluggish recently. Any ideas why?

    Unsolved
    19
    0 Votes
    19 Posts
    1k Views
    S
    @Valso said in Qt (maybe 5) became sluggish recently. Any ideas why?: Now I installed these two and forced them to use the GTK file dialogs, so no more waiting for an eternity for the dialog to load. Then it sounds like a problem of KDE and not Qt. Yes, KDE is closely related to Qt, but it also extends Qt. Most likely it provides its own "native" file dialog for Qt. There is a difference between plain Qt programs and KDE programs. And you were (almost) right initially that KDE would imply Linux as OS, but Qt actually does not (as mentioned before). (Just for completeness sake: the official KDE programs are also available on Windows. I even have Kate installed.)
  • qAsConst() deprecated

    Solved
    4
    0 Votes
    4 Posts
    2k Views
    C
    @Chris-Kawa Thanks so much Chris. You have saved me from making a systematic errror. Much appreciated.
  • windeployqt via docker issue

    Unsolved
    1
    0 Votes
    1 Posts
    125 Views
    No one has replied
  • 0 Votes
    5 Posts
    1k Views
    KH-219DesignK
    @johnco3 said in porting qmake pro file to mac - library issue: how I should use or handle the environment variables that point to the homebrew directories? I have a sample project (my own "living cheatsheet") that compiles a Qt GUI for mac (and other platforms). You don't have to take my word for it, you can look at the Github "Actions" (continuous integration) to see that the builds are succeeding. My "cheatsheet" project: uses homebrew: https://github.com/219-design/qt-qml-project-template-with-ci/blob/master/tools/ci/provision_mac.sh#L10 makes minor use of macx blocks in pro/pri files For my baseline project, the only macx blocks I seem to need are the following "quality of life improvements": ios|macx { # the lines below suppress warnings generated by Qt's header files: we tell # Clang to treat Qt's (mac) Framework headers as "system headers": QMAKE_CXXFLAGS += -iframework $$[QT_INSTALL_LIBS] QMAKE_CXXFLAGS += -isystem $$[QT_INSTALL_LIBS]/QtCore.framework/Headers } and ios|macx { # Disable a couple that are more onerous to comply with on Mac QMAKE_CXXFLAGS += "\ -Wno-error=missing-noreturn \ -Wno-error=sign-conversion \ " } (in the file https://github.com/219-design/qt-qml-project-template-with-ci/blob/master/compiler_flags.pri) However, the baseline project does not link to anything from homebrew. On another project (not public on github), here are some other snippets I have used: macx { # MacOSX homebrew puts the mysql.h header elsewhere: QMAKE_CXXFLAGS += -isystem /usr/local/include/mysql } macx { LIBS += -L/usr/local/lib -lmysqlclient } Once your code compiles, you will very likely find yourself face-to-face with another common MacOS hurdle: the app bundle. Reference: https://developer.apple.com/go/?id=bundle-structure In order to make a bundle that will launch (so you can actually launch your app), the Qt "magic" you will need is macdeployqt: https://github.com/219-design/qt-qml-project-template-with-ci/blob/master/build_app.sh#L91
  • QJniObject::construct -> how to use?

    Unsolved
    2
    0 Votes
    2 Posts
    272 Views
    JonBJ
    @Flaming-Moe QJniObject::construct<jstring>() will be correct for "no arguments to constructor", else you would have to specify them inside the (...). I also get a complaint Might help us if you showed the "complaint" message....
  • How to close SecondaryWindow from non-caller function

    Unsolved
    6
    0 Votes
    6 Posts
    347 Views
    Pl45m4P
    @JonB Then the title of this is weird...
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    20 Views
    No one has replied
  • 0 Votes
    19 Posts
    3k Views
    S
    @Chris-Kawa thank you very much. That definitely helped a lot. :) I have done the manual positioning now, so all delegates line up with the actual widget. :) void ViewLayerItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { QStyleOptionViewItem opt = option; initStyleOption(&opt, index); // Überprüfen Sie, ob der aktuelle Index bearbeitet wird if (index == currentlyEditedIndex) { return; } // Setzen Sie die Werte der SpinBox und CheckBox basierend auf den Modellwerten QString lineEditvalue = index.model()->data(index, Qt::EditRole).toString(); bool checkBoxValue = index.model()->data(index, Qt::CheckStateRole).toBool(); // Laden Sie das Icon und skalieren Sie es QPixmap iconPixmap("://resource/quick.png"); // Ersetzen Sie dies durch den Pfad zu Ihrer Icon-Datei QPixmap scaledPixmap = iconPixmap.scaled(32, 32, Qt::KeepAspectRatio, Qt::SmoothTransformation); // Berechnen Sie die Position für das Icon int centerY = option.rect.top() + option.rect.height() / 2; int iconY = centerY - scaledPixmap.height() / 2; QPoint iconPos = QPoint(option.rect.left() + 10, iconY); // Zeichnen Sie das Pixmap mit dem QPainter painter->drawPixmap(iconPos, scaledPixmap); // Berechnen Sie die Position und Größe für das LineEdit QRect lineEditRect = option.rect; lineEditRect.setLeft(iconPos.x() + scaledPixmap.width() + 10); // Adjust as needed lineEditRect.setRight(option.rect.right() - 10); // Adjust as needed // Erstellen Sie ein QStyleOptionFrame für das LineEdit QStyleOptionFrame lineEditOption; lineEditOption.lineWidth = 1; // Setzen Sie die Liniendicke auf 1 lineEditOption.rect = lineEditRect; // Zeichnen Sie das LineEdit QApplication::style()->drawControl(QStyle::CE_ShapedFrame, &lineEditOption, painter); // Zeichnen Sie den Text des LineEdits painter->drawText(lineEditOption.rect.adjusted(2,0,0,0), Qt::AlignLeft | Qt::AlignVCenter, lineEditvalue); // Berechnen Sie die Position und Größe für die CheckBox QRect checkBoxRect = option.rect; checkBoxRect.setLeft(lineEditRect.right() - 22); // Adjust as needed checkBoxRect.setRight(option.rect.right() - 10); // Adjust as needed // Erstellen Sie ein QStyleOptionButton für die CheckBox QStyleOptionButton checkBoxOption; checkBoxOption.state = checkBoxValue ? QStyle::State_On : QStyle::State_Off; checkBoxOption.rect = checkBoxRect; // Zeichnen Sie die CheckBox QApplication::style()->drawControl(QStyle::CE_CheckBox, &checkBoxOption, painter); }
  • How to use openssl libraries in qt cmakelist.txt

    Unsolved
    5
    0 Votes
    5 Posts
    714 Views
    P
    @ChrisW67 Thanks for your answer . I have referred to the document [image: f2f4d3e2-f648-40b7-9c62-489d8e0b47ed.png] https://wiki.qt.io/Compiling_OpenSSL_with_MinGW but while building project in windows environment . I am getting error that some libraries are not found . Which are of openssl . Also another approach which i followed is directly installing openssl using it's installer ,it worked but i want to compile it and make it work .Help me out please.
  • Rationale for QIntValidator behaviour

    Unsolved
    5
    0 Votes
    5 Posts
    338 Views
    S
    It is really annoying (as a user) if you could not type in 999 and then change it to 899 later. If you're in the flow it is not directly obvious why this should fail, even if the upper limit is 900. We have some checks of floating point input fields in our software ported several times from other GUI frameworks that get really annoying at times. So, I am advocating for this kind of editing behavior. Yes, it makes the programmer's job harder, but it is worth it for the end user.
  • qt.multimedia.player: Warning: "Failed to connect: Connection refused"

    Solved
    15
    0 Votes
    15 Posts
    2k Views
    C
    It is possible there is an issue with Qt Creator. I saw the error when running inside Qt Creator, but not when running from the command line.
  • QListView Not Displaying Anything

    Unsolved
    5
    0 Votes
    5 Posts
    506 Views
    C
    @SGaist thanks for the suggestion. There's no real reason why the string list was a pointer - likely just copying what was being done for the model and the delegate. This code is being converted from a 15-year old application written to use MFC, so I have to keep shaking the "MFC-think" out of my head.