Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • Converting QByteArray to QString

    Unsolved qbytearray qstring qprocess
    13
    0 Votes
    13 Posts
    11k Views
    C
    @Sina-Ranjkesh-zade said in Converting QByteArray to QString: For "standard input" if you mean input arguments of the process, I got this error: No, I meant standard input. That is , the python program reads from a terminal and accepts input just as if you typed it (except it is the Qt program sending that input). The Qt program can send a command to the python program, send the data it needs, and read the result (if there is one) back on the python program's standard output. Or you can used shared memory, or a socket, or files, or do whatever the python program is doing in the Qt program...
  • QDataStream and long double

    Unsolved
    4
    0 Votes
    4 Posts
    343 Views
    Kent-DorfmanK
    AUTOSAR-A0-4-2 rule for safety critical c++ applications: Type long double shall not be used. The width of long double type, and therefore width of the significand, is implementation defined.
  • Qt Debug Symbols

    Unsolved
    2
    0 Votes
    2 Posts
    342 Views
    Chris KawaC
    As the name and description suggest - installs debugging symbols (pdb files on Windows) that you can use to debug Qt Creator itself.
  • I would need someone to teach me some things about QScrollArea.

    Unsolved
    6
    0 Votes
    6 Posts
    296 Views
    SGaistS
    I gave you the full chain of inheritance back to QWidget. Yes you can put a layout on an QScrollArea. As already said by @Pl45m4, it's not what you do when you want to use QScrollArea to manage a widget bigger than for example the screen. Still, there might be cases where putting something in a layout on a QScrollArea could make sense. However I do not have an example at hand.
  • QAudioDecoder not emitting signals

    Solved
    3
    0 Votes
    3 Posts
    261 Views
    D
    okay turns out i wasn't creating the thread correctly. when i switched to "worker thread" style as explained here, it all started working. :)
  • QLayouts in a QScrollarea

    Unsolved
    4
    0 Votes
    4 Posts
    315 Views
    C
    @SGaist thanks for that. It's just an example you know. But all the same, I will keep this in mind.
  • working example of QMessage

    Unsolved
    4
    0 Votes
    4 Posts
    427 Views
    B
    As a general point, I prefer using usual C++ std::string (they all are UTF8 encoded), or C const char* string (UTF8). The reason is more political than technical: I am afraid that in 2021, funding agencies prefer Web interfaces to Qt ones (on desktops or laptops) for software having several human users at once. Also, RefPerSys being today a research project, efficiency is not a priority, and losing CPU time in lots of std::string to QString conversion (and vice versa) is now (july 2021) acceptable. Our long term vision is to generate C++ code (from our higher-level declarative formalism, expert system like). Ideally, like Pitrat explains in his Artificial Beings: the Conscience of a Conscious Machine book (ISBN 978-1848211018), we want to generate all the C++ code of RefPerSys. Of course, that is an ambitious goal, and we are very far from it. Sadly, in july 2021, we have very few generated C++ lines. BTW, Jacques Pitrat was the director of my PhD jury, defended in Paris in 1990. The local variable obshowstring is declared as std::string obshowstring in file tempgui-qrps.cc, for commit 7fa10ba9cd62 in line 331 Regards, and thanks for your help. Basile Starynkevitch - near Paris in France PS. Off-topic: I am interested in any HorizonEurope submission which could fund RefPerSys. The RefPerSys website mentions some potential calls (e.g. HORIZON-CL2-DEMOCRACY-2022-01-01, HORIZON-CL2-DEMOCRACY-2022-01-05, HORIZON-CL2-DEMOCRACY-2022-01-06, HORIZON-CL2-HERITAGE-2022-01-03, HORIZON-CL2-HERITAGE-2022-01-04, HORIZON-CL2-HERITAGE-2022-01-06, HORIZON-HLTH-2021-STAYHLTH-01-02, HORIZON-HLTH-2022-STAYHLTH-01-01, HORIZON-HLTH-2022-STAYHLTH-01-04, HORIZON-HLTH-2022-STAYHLTH-02-01 but there could be others. Contact me then by email to both basile@starynkevitch.net (personal email) and to basile.starynkevitch@cea.fr (professional email at CEA LIST)
  • 0 Votes
    5 Posts
    363 Views
    C
    @Pl45m4 your edited comment is a better criticism than what you initially posted. Anyway, thanks for your contribution.
  • Real confusion about when to delete QNetworkReply object

    Solved
    31
    0 Votes
    31 Posts
    3k Views
    H
    @SGaist you can use dynamic properties to keep everything in one place Didn't understand what you meant use a QMap to store the reply specific data that you will then grab in your lambda Could you provide a minimal sample code on how to do that
  • Clear background when implementing drawBackground

    Solved
    9
    0 Votes
    9 Posts
    1k Views
    M
    That's interesting that the setBackground(QBrush()) works for you. Looking at the code, QGraphicsScene::drawBackground() doesn't do anything when the background brush is Qt::NoBrush (which is what QBrush() is). Not sure what Q_D(QGraphicsScene) does; it's called at the beginning of many QGraphicsScene methods but I didn't see where it was defined. This is the code from Qt 5.12: void QGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect) { Q_D(QGraphicsScene); if (d->backgroundBrush.style() != Qt::NoBrush) { if (d->painterStateProtection) painter->save(); painter->setBrushOrigin(0, 0); painter->fillRect(rect, backgroundBrush()); if (d->painterStateProtection) painter->restore(); } }
  • Is it possible to open QtVirtualKeyboard by code?

    Solved
    3
    0 Votes
    3 Posts
    267 Views
    Y
    @raven-worx Thank you once again, this solution was spot on :-) Kind regards, Yina
  • How to pass SIGNAL parameter(s) to SLOT as SAME parameters ?

    Unsolved
    2
    0 Votes
    2 Posts
    278 Views
    Chris KawaC
    SIGNAL(currentItemChanged(QListWidgetItem * current, QListWidgetItem * previous)) This code is not valid. You don't pass parameter names to SIGNAL macro, only the types. It should be SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)) how does SIGNAL process (...) parameters SIGNAL macro just stringifies the function name and parameters, so if you have a void something(int) signal it creates a string in a unified format like "2something(int)" (just an example, the actual format of that string is internal and not important to you). Same goes for the SLOT macro. Internally connect uses these strings to match function signatures. If, for educational reasons, you're curious what the format of that string is you can just write it out: qDebug() << SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)); how does SIGNAL (...) acquire parameters and HOW to pass them to slot . The code that emits that signal just passes them, so for example some function in the QListWidget will have: void QListWidget::something() { ... QListWidgetItem* current = ...; QListWidgetItem* previous = ...; emit currentItemChanged(current, previous); ... } Emiting a signal like emit someSignal(42) is conceptually something like this (in pseudo code). This is what moc generates as the function body of that signal: void someSignal(int param) { foreach (connected_slots) { if (stringified_signature_of_signal matches stringified_signature_of_slot) slot(param); } } can I envision these parameters as some kind of global variable ? I'm not sure what you mean. You're getting them in the slot so you can see them there. If you want to inspect them before the signal is emitted just set a breakpoint where the signal is emitted. In your example you ignore signal parameters. If you want to inspect them in the slot you need to change the slot signature to receive them: void testSlot(QListWidgetItem * current, QListWidgetItem * previous) and change your connect statement accordingly to use SLOT(testSlot(QListWidgetItem*, QListWidgetItem*))
  • Reading xml file using Qdomdocument, chlidnode count not coming correct

    Solved
    7
    0 Votes
    7 Posts
    806 Views
    N
    yes, i understood thanks
  • Where is QLineEdit's text drawn in QStyle?

    Unsolved qpalette qstyle
    3
    0 Votes
    3 Posts
    859 Views
    CJhaC
    @mrjj Thanks, it seems like odd behaviour. So, it uses its native palette, i.e. the palette set either directly or inherited from its parent. I am able to change the colour now, but I am using a C-Style cast, and that's why I am not sure if I should do it. Here is my solution: void GuiStyle::drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const { if(vars[id].customTheme) { if(element == QStyle::PE_PanelLineEdit) { const QStyleOptionFrame* comboOption = qstyleoption_cast<const QStyleOptionFrame*>(option); QStyleOptionFrame newComboOption = *comboOption; newComboOption.palette.setBrush(QPalette::Base, Qt::red); // I am using C-Style cast to get the widget in a non-const pointer and then it's palette again the same way QLineEdit* lineEditPtr = (QLineEdit*)widget; QPalette pal = (QPalette)lineEditPtr->palette(); pal.setColor(QPalette::Text, Qt::green); lineEditPtr->setPalette(pal); QProxyStyle::drawPrimitive(element, &newComboOption, painter, widget); } } else { QProxyStyle::drawPrimitive(element, option, painter, widget); } }
  • build in linux

    Unsolved
    2
    0 Votes
    2 Posts
    237 Views
    JonBJ
    @Mc6bullet Are these entries you have created yourself, or something from Qt? If from Qt then presumably something needs configuring to use Linux commands instead. If your own: in a Windows Command Prompt type xcopy /? to understand its existing usage. Then translate to the equivalent in Linux. I would suggest you might need to use rcp, or perhaps cp -r will suffice. Use man rcp or man cp to see their usages.
  • Why i am gettting error: 'QtMsgHandler' does not name a type' ?

    Unsolved
    9
    0 Votes
    9 Posts
    439 Views
    Q
    @Christian-Ehrlicher Sorry for trying that.
  • setStyleSheet via .qss file

    Solved
    5
    0 Votes
    5 Posts
    2k Views
    E
    @jsulm With resource file it is working thanks.
  • i want to on and off this log at runtime how to achieve this thing efficiently in qt ?

    Locked Unsolved
    2
    0 Votes
    2 Posts
    145 Views
    Christian EhrlicherC
    Please write a proper question - closed!
  • Change property of a class during runtime

    Unsolved qstyle qspinbox
    1
    0 Votes
    1 Posts
    260 Views
    No one has replied
  • How to add log4j library in qt ?

    Solved
    3
    0 Votes
    3 Posts
    266 Views
    Q
    @jsulm Is there any logger system is there like log4j in qt whose log i can on and off in file as per my need ?