Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • How to restart a thread?

    Unsolved
    3
    0 Votes
    3 Posts
    746 Views
    W
    @JKSH said in How to restart a thread?: If your VideoBurner object is in the middle of a calculation and you quit the event loop, your VideoBurner will enter "suspended animation". It will remain stuck in its half-calculated state... and then it will continue the calculation when the event loop is restarted. To avoid that, you must get your VideoBurner object to discard its incomplete calculations when you want to quit. Thank you for the info, I'll search for how to achieve this.
  • QT Designer - How to create a layout

    Unsolved
    3
    0 Votes
    3 Posts
    337 Views
    V
    @Pablo-J-Rogina In the documentation doesn't sais anything regarding my needs, just some basic layout options which I know it already, and on the layout manager, it's all about C++. So if you are telling me about this layout managemt link that means there is no way of doing this just by using QT Designer?
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • 0 Votes
    1 Posts
    398 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Limit total number of completions in QCompleter

    Solved
    8
    0 Votes
    8 Posts
    792 Views
    L
    I ended up creating a QSortFilterProxyModel derived class with a limited row count and set that as the model for QCompleter and do the searching/filtering with that model instead of QCompleter, so the relationship goes as follows: Original model <-> Proxy model -> QCompleter ^ | QTextEdit
  • Parsing incomplete json array on QTcpSocket readyRead() , unterminated string

    Solved
    12
    0 Votes
    12 Posts
    1k Views
    R
    @KroMignon said in Parsing incomplete json array on QTcpSocket readyRead() , unterminated string: @rifky said in Parsing incomplete json array on QTcpSocket readyRead() , unterminated string: solved , maybe it's not a great solution, but it solves my problem As @jsulm has written, the best way is to declare a class member to store temporary value. Then, according to your example, you are search a string with is between []. So one solution would be something like this: class SocksUpdata : public QObject { Q_OBJECT private: QByteArray _buffer; ... }; QByteArray SocksUpdata::getData() { _buffer.append(tcpSocketUpdata->readAll()); int idx = _buffer.indexOf('['); if(_buffer[0] != '[' && idx > 0) { _buffer.remove(0, idx); } idx = _buffer.indexOf(']'); if(_buffer[0] == '[' && idx > 0) { QByteArray byte_json = _buffer.left(idx+1); _buffer.remove(0, idx+1); QJsonParseError parseErr; QJsonDocument doc = QJsonDocument::fromJson(byte_json, &parseErr); if(parseError_2.error != QJsonParseError::NoError) { emit setJsonInvalid(this->epoch, byte_json); } else { // do your stuff } } } thx alot sir, it's working . i got little bit confuse using QbyteArray, i'm trying to made my code working with QHash wich can storing QByteArray, thx for help i'm realy appriciate that :)
  • Embedded a qwt3d example into my project

    Unsolved
    1
    0 Votes
    1 Posts
    137 Views
    No one has replied
  • QT class default access modifier

    Solved
    4
    0 Votes
    4 Posts
    257 Views
    SGaistS
    That's unrelated to Qt. I have the habit of keeping things in order together by type. All public methods together, then the protected and then the private. And then again with the variables.
  • How to resize interface as per mobile screen

    Unsolved
    1
    0 Votes
    1 Posts
    107 Views
    No one has replied
  • Networking: arp-request in Unix

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    Kent-DorfmanK
    There are many ways to do what you seek in linux, just none are Qt specific. It's a Linux systems programming exercise, not Qt. Firstly, you're not going to get a real MAC address for any IP that isn't directly connected. You may get the MAC of the router gateway though. I'd just send a dgram to the destination IP, then read /proc/net/arp to see if an entry was added.
  • QDebug, inheritance QObject issue ambiguous call

    Unsolved qdebug
    6
    0 Votes
    6 Posts
    1k Views
    jeremy_kJ
    Anything to make one definition more specific should work. My ability to recall the full set of rules is clearly less than perfect.
  • Undo redo for vtk widgets

    Unsolved
    6
    0 Votes
    6 Posts
    665 Views
    SGaistS
    @zandarina why can it not be used with VTK widgets ? The QUndo framework is not tied to any specific widgets type. It's generic.
  • How to improve anti-aliasing?

    Solved
    4
    0 Votes
    4 Posts
    2k Views
    CJhaC
    @CJha Found a solution. This works quite fast, 100k data points plotted in around 15 - 20 ms. void mainWindow::paintEvent(QPaintEvent *event) { /* Constructing Line Plot */ double numOfPoints{100000}; // Data Length is 100 Thousand QVector<double> data; // Data Vector of 100 Thousand for(int ii = 0; ii < numOfPoints; ++ii) { // Sine Wave: Amplitude = 1; Frequency = 10 data << (1 * sin (2 * M_PI * 5 * ii/numOfPoints)); } int midPoint = round(numOfPoints/2); data[midPoint] = 2; // Adding a single point of amplitude 2 at 50 thousandth data point double dataMin{-1}; // Minimum amplitude of data double dataMax{2}; // Maximum amplitude of data /* Setting up Painter */ QPainter p(this); p.setPen(Qt::blue); p.setRenderHint(QPainter::Antialiasing); QPolygonF polyline; // To draw lines to connect two points with different x-coordinates QPainterPath path; // To draw abstract lines with same x-coordinate but different y-coordinates /* NOTE: QPainter path is used because it has a moveTo functionality i.e. path's coordinates can be changed without creating a line from previous coordinate to new one. Same is not true for QPolygonF and so it is used to draw the continuous line */ /************************************************ ***** Mapping Data to rect() of mainWindow ***** ************************************************/ QVector<int> py; // Point Y QVector<int> sy; // Serial Y QVector<int> sySize; // Sizes of sy QVector<double> val; // Y Value for different groups of data int x_cur{0}; // x-value for current data set int x_prv{0}; // x-value for previous data set int y{0}; int majy{0}; // Major Y i.e. the value which QPolygonF will follow double miny{0}; // Minimum Y: Start Point of QPainterPath double maxy{0}; // Minimum Y: End Point of QPainterPath int idy{0}; // ID to identity Value of Major Y /* This only works for data size larger than width of screen. For data size smaller than screen a much simpler approach is used but is not shown here */ if(data.size() > width()) { path.clear(); for(int ii = 0; ii < (width() + 1); ++ii) { py.clear(); x_cur = round(ii * (numOfPoints/width())); if(ii != 0) { for(int jj = x_prv; jj < x_cur; ++jj) { y = round(height() * (dataMin + (dataMax - dataMin) - data[jj]) / (dataMax - dataMin)); if(!py.contains(y)) { py << y; } } if(py.size() == 1) { polyline << QPointF((ii - 1.0), py[0]); } else { std::sort(py.begin(), py.end()); sy.clear(); sySize.clear(); val.clear(); majy = 0; miny = 0.0; maxy = 0.0; idy = 0; for(int jj = 0; jj < py.size(); ++jj) { if(jj == 0) { sy << py[jj]; } else { if(py[jj] == (py[jj - 1] + 1)) { sy << py[jj]; } else { double newVal{0.0}; for(int kk = 0; kk < sy.size(); ++kk) { newVal = newVal + sy[kk]; } val.append(newVal / sy.size()); sySize << sy.size(); sy.clear(); sy << py[jj]; } } } double newVal{0.0}; for(int kk = 0; kk < sy.size(); ++kk) { newVal = newVal + sy[kk]; } val.append(newVal / sy.size()); sySize << sy.size(); if (val.size() == 1) { polyline << QPointF((ii - 1.0), val[0]); } else { for(int kk = 0; kk < sySize.size(); ++kk) { if(sySize[kk] > majy) { majy = sySize[kk]; idy = kk; } } auto result = std::minmax_element(val.begin(), val.end()); miny = *result.first; maxy = *result.second; polyline << QPointF((ii - 1.0), val[idy]); path.moveTo(QPointF((ii - 1.0), miny)); path.lineTo(QPointF((ii - 1.0), maxy)); } } } x_prv = x_cur; } } p.drawPolyline(polyline); p.drawPath(path); } At the end this is what I get: [image: 82b17c21-c4fe-49f0-88dc-9aa6374ee4f5.PNG]
  • How to get gstreamer inside of GUI

    Unsolved
    6
    0 Votes
    6 Posts
    521 Views
    SGaistS
    Can you test the version provided by your distribution ?
  • QGraphicsView::scale not working

    Unsolved
    1
    0 Votes
    1 Posts
    126 Views
    No one has replied
  • Question re: multiple inheritance with QWidgets

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    D
    @Bonnie - Thank you for the documentation reference - that was very helpful.
  • Function not always returning if called in thread???

    Solved
    6
    0 Votes
    6 Posts
    492 Views
    EngelardE
    @JKSH said in Function not always returning if called in thread???: Your code has race conditions. You must protect data/objects that are accessed by multiple threads: https://en.wikipedia.org/wiki/Race_condition#Software Hey, that's very informative link! Thats fully explains what happening during execution of my func. Thanks. It's good to know again, that Earth spinning around the Sun, gravity pulls things down and programs does'nt run forward until they finish execution of the function. Result: At the first i invented some upgrade, added second (predefined)parameter: static void reportToConsole(QString msg, int pause=0) { tBrowPtr->append("<font color=\"#808080\">"+currentTime()+ ":</font color>"+msg); if(pause!=0) Sleep(pause); } I could specify some amout of mSecs to wait, if func used in my Thread loop. Works well, but then i read that stuff @JKSH posted, and realized that even specifying 20 or even 30 msecs - not guaranteeing safe execution. App simply could be running at old slow PC, and those mSecs amount might not be enough. So i creating simple "another" function which connects MainWindow and Worker, so error send from the worker will be executed in MainWindow SLOT. Like in old days... Now the only tiny thing left - how can i forbid Workers thread use my global common function instead of emiting Signal. Could accidentally, call wrong reportToConsole)
  • 0 Votes
    3 Posts
    384 Views
    B
    It's quite usual to have some COM warnings in debug mode. I would ignore those if there're no other problems.
  • How to detect multi screen with eglfs?

    Unsolved
    3
    0 Votes
    3 Posts
    307 Views
    mrjjM
    Hi As far as i know, eglfs does not support multiple displays. https://forum.qt.io/topic/88111/imx6-multi-screen-use-eglfs