Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.4k Posts
  • Hoiw to implement "QT_MESSAGE_PATTERN

    Unsolved
    3
    0 Votes
    3 Posts
    550 Views
    Paul ColbyP
    Hi @AnneRanch I like to colorize parts (text) of the QDebug output. Here's how I do it in one of my open-source projects: #if defined(Q_OS_UNIX) #include <unistd.h> #elif defined(Q_OS_WIN) #include <Windows.h> #endif inline bool haveConsole() { #if defined(Q_OS_UNIX) return isatty(STDERR_FILENO); #elif defined(Q_OS_WIN) return GetConsoleWindow(); #else return false; #endif } void configureLogging(const QCommandLineParser &parser) { // Start with the Qt default message pattern (see qtbase:::qlogging.cpp:defaultPattern) QString messagePattern = QStringLiteral("%{if-category}%{category}: %{endif}%{message}"); if (parser.isSet(QStringLiteral("debug"))) { #ifdef QT_MESSAGELOGCONTEXT // %{file}, %{line} and %{function} are only available when QT_MESSAGELOGCONTEXT is set. messagePattern.prepend(QStringLiteral("%{function} ")); #endif messagePattern.prepend(QStringLiteral("%{time process} %{threadid} %{type} ")); } const QString color = parser.value(QStringLiteral("color")); if ((color == QStringLiteral("yes")) || (color == QStringLiteral("auto") && haveConsole())) { messagePattern.prepend(QStringLiteral( "%{if-debug}\x1b[37m%{endif}" // White "%{if-info}\x1b[32m%{endif}" // Green "%{if-warning}\x1b[35m%{endif}" // Magenta "%{if-critical}\x1b[31m%{endif}" // Red "%{if-fatal}\x1b[31;1m%{endif}")); // Red and bold messagePattern.append(QStringLiteral("\x1b[0m")); // Reset. } qSetMessagePattern(messagePattern); } Cheers.
  • OK, I asked before ... but what are these ?

    Unsolved
    2
    0 Votes
    2 Posts
    212 Views
    Axel SpoerlA
    what are they, Build folders. and what makes them , The compiler. and why Because something was compiled. ?? Why two question marks? Does it mean, you’ll ask the question again in a while? Or was the question mark forgotten the first time? I am confused.
  • Perfectly overlapping Q labels

    Unsolved
    2
    0 Votes
    2 Posts
    333 Views
    SGaistS
    Hi, QStackedWidget comes to mind for that. Put your labels in it and the buttons underneath.
  • How to find MQTT examples

    Unsolved
    15
    0 Votes
    15 Posts
    2k Views
    SGaistS
    @lukutis222 AFAIK, pre-built binaries for that module are available for commercial license holder. As for Qt Creator, most likely because Qt Creator is way younger than Qt itself and has likely not yet been used as much as other means to develop Qt. Note that having for example the qtbase completely loaded in an IDE is a pretty intensive task which might not even be doable due to the sheer size of the module. However, additional documentation on that matter would be something good.
  • Unable to Move Window Between Screens in Wayland

    Unsolved
    2
    0 Votes
    2 Posts
    943 Views
    SGaistS
    Hi, The reason is: it's a Wayland "feature" not something that Qt can do anything about. You could use a custom compositor that does not follow the official API but that's at your own risk.
  • QtCreator crashes when adding the path to Android NDK list on Android settings

    Unsolved
    2
    0 Votes
    2 Posts
    236 Views
    tomyT
    Qt Creator 10.0.0 IDE is the best amongst its prior versions for crashing so that I have to rise Task Manager each time just to terminate it! Wow great job creating that! A true piece of shit.
  • color individual points separately in QScatterSeries of Qt Charts

    Unsolved
    1
    0 Votes
    1 Posts
    539 Views
    No one has replied
  • QImage not opening 16-bit png (AFAICT)

    Solved
    2
    0 Votes
    2 Posts
    340 Views
    PerdrixP
    @Perdrix Woohoo! I found QImageReader::setAllocationLimit()
  • qt creator9 along with qt6.4 doesnt compile WYSIWYG, not similar with preview

    Unsolved
    14
    0 Votes
    14 Posts
    4k Views
    ?
    @Christian-Ehrlicher @ChrisW67 Thank you for your help. Here is an MVP of what shows the problem. Would you please tell me If I am doing layouts wrongly? Or should it be handled in other ways for high dpi management? https://drive.google.com/file/d/1oPCpIctbh9lgRSMbFnIiTSZmLba0I3R2/view?usp=sharing
  • Qt installator doesn't show components in Ubuntu 22.04

    Solved
    10
    0 Votes
    10 Posts
    2k Views
    C
    @Abderrahmene_Rayene I did "sudo apt-get install qtbase5-dev" , after this I ran the qt installer and the components appeared in the installer.
  • How to build WM_KEYDOWN|UP LPARAM from a QKeyEvent?

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    Chris KawaC
    @Ylvy said: I didn't understand this ll thing, based on these two examples i gave (wParam of wheel and lParam of KeyEvent) is it still possible to it construct wrong messages at sometime or is it correct now? LPARAM is a typedef for __int64, which is Microsoft's extension type name for 64bit signed integers (same as int64_t in modern C++), so when dealing with constants for it you should be using signed 64bit integers, for example 1LL. As @JonB said it stands for long long int, which is the old way of standard C++ to mean "at least 64 bit" (it is always 64 bit on 64bit Windows). WPARAM is a typedef for unsigned __int64, so when dealing with it you should be using unsigned 64bit integers, for example 1uLL, which stands for unsigned long long int. The type of (1<<31) expression is int, since all operands are int and that is a 32bit signed integer on Windows. When using it in expression like lParam | (1 << 31) it gets upcasted to 64bit type, because the left operand is a signed 64bit value. (1<<31) is a negative 32bit signed value, so when upcasted to 64bit you get 11111... at the extended part of the 64bit value (C++ uses Two's complement binary representation), which caused your problem. A type of (1LL << 31) expression is long long, since the left operand is a long long constant. It already is a 64bit value with 00000.... on the first 32 bits, so there's no upcasing needed when you | it with lParam. Btw. keep in mind that what I said is about 64bit Windows. If you target 32bit Windows too then LPARAM and WPARAM are typedefs for 32bit types long and unsigned int, so use 32bit constants there. A side question, why Qt use a different value for the key modifiers Qt::ControlModifier, etc, than Microsoft? Why should it be the same as Microsoft? Qt is a cross-platform framework with roots in Linux. I don't see any reason why it should use the same values for private implementation as any particular vendor, not just Microsoft.
  • Qt without qmake and the .pro file

    Unsolved
    6
    0 Votes
    6 Posts
    500 Views
    JoeCFDJ
    @clarify not sure which Qt version you are using? From Qt6 cmake is preferred. I saw most of Qt6 examples have both cmake and qmake. Better to switch now.
  • Adding custom port to "terminal" example - bump

    Unsolved
    6
    0 Votes
    6 Posts
    347 Views
    A
    @Pl45m4 I finally found the code which actually reads the system available serial ports... it is a challenge to start with "update settings" and go backwards... Temporary / partially solved
  • QPlaintTextEdit shows nonprintable characters

    Unsolved
    2
    0 Votes
    2 Posts
    215 Views
    SGaistS
    Hi, Which characters are you currently seeing ?
  • QTableWidget has no cellRightClicked

    Unsolved
    2
    0 Votes
    2 Posts
    261 Views
    JonBJ
    @clarify Right clicking on widgets is normally handled as a context menu request. For a QTableWidget right click on cell example, see e.g. @SGaist's code at https://forum.qt.io/topic/94905/simpliest-way-for-creating-contextmenu-for-qtablewidget-cells/5.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    3 Views
    No one has replied
  • Drag and drop with drawing lines between items

    Unsolved
    2
    0 Votes
    2 Posts
    307 Views
    JonBJ
    @Jessevg Hi. I'm not an expert on the terminology, haven't used UML, but I term this a "flow chart", right? Qt provides Diagram Scene Example for a simple one/the principles. If you want to start from someone else's work, I Googled Qt flow chart. There seems to be a https://github.com/floji/floji, don't know what it does/how good it is. Or Google Qt UML. Qt itself has a "model editor to create Universal Modeling Language (UML) style models". I don't know whether you can use this, use this for inspiration, or if the sources are provided.
  • no query unable to fetch row

    Solved
    17
    0 Votes
    17 Posts
    5k Views
    M
    I was having a similar issue, but in my case I didn't realize that the QSqlQuery constructor executes the SQL immediately if you pass in the string. That created the "unable to fetch row" condition when I subsequently called .exec since I was erroneously instructing it to run the same query again.
  • Layout: Draw a button widget over the image drawn on the qlabel.

    Solved
    7
    0 Votes
    7 Posts
    688 Views
    M
    @jsulm Thanks so much :) buttonLayout = new QHBoxLayout(ui->label); buttonLayout->addWidget(ui->beginBtn); buttonLayout->addWidget(ui->prevBtn); buttonLayout->addWidget(ui->nextBtn); buttonLayout->addWidget(ui->endBtn); buttonLayout->setAlignment(Qt::AlignBottom | Qt::AlignCenter); However, since the qlabel is adjusted to the size of the image, the location of the button moves according to the size of the image. The button disappears when the picture size is larger than the window and there is a scroll bar. I guess I can fix it so that it is always centered under the window. thank you
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    33 Views