Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.5k Posts
  • 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
    495 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
  • Changine Palette to Dark, doesn´t change everything.

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    Pl45m4P
    @BDC_Patrick If your QToolBar's name is toolBar and you want to change only this specific toolbar, then it would be ("QToolBar#toolBar { . . . } ");
  • mouseWheel event for QHeaderView of a QTableWidget

    Unsolved
    7
    0 Votes
    7 Posts
    2k Views
    Christian EhrlicherC
    @Adam-Crowe said in mouseWheel event for QHeaderView of a QTableWidget: The eventFilter does receive the QEvent::Wheel event but I haven't managed to pass it on to either the MyTableWidget itself (presumably to be then caught by the wheelEvent above which does work already) or just return false or do an event->ignore() on it. Please show some code... minimal, fully compilable.
  • Get nested json values

    Unsolved
    20
    0 Votes
    20 Posts
    5k Views
    JonBJ
    @avmg Yes. Note that we are saying you can read nested JSON objects via qDebug() << json["Food"].toObject()["Fruits"].toObject()["Apples"]; but you cannot write the value of a nested object via json["Food"].toObject()["Fruits"].toObject()["Apples"] = 10; That's just how it is, as the code above copies the JSON objects, so assigning does not change what is in json[].... If you want to achieve the second example you have to build it up bit by bit as per the 4 lines QJsonObject json, food, fruits; fruits["Apples"] = 10; food["Fruits"] = fruits; json["Food"] = food;
  • Mysql To Excel

    Solved
    2
    0 Votes
    2 Posts
    223 Views
    JonBJ
    @Ketan__Patel__0011 From a Qt programming point of view, just read from tables outputting columns with a , separator to a .csv file, and read that into Excel. If you want external tools to do it, just Google for Mysql To Excel. There is a whole chapter in the MySQL docs https://dev.mysql.com/doc/mysql-for-excel/en/mysql-for-excel-import.html.
  • 0 Votes
    4 Posts
    1k Views
    JKSHJ
    @ricardovaras_99 said in What library should I use for animation in Qt Widgets Application?: And I want to simulate water level increasing on a tank. Do you want to animate the water level (in other words, make the level rise or fall at a specific speed in real time)? Or do you just want to display the water level? (in other words, make the picture show the latest level)? If you want the latter, have a look at the Qt Quick Coffee Machine demo: Video: https://resources.qt.io/videos/built-with-qt-qt-quick-coffee-machine-demo-qtws17 Code: https://doc.qt.io/qt-5/qtdoc-demos-coffee-example.html
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Jom Error 2 while building sources from qt5.git dev branch

    Solved
    9
    0 Votes
    9 Posts
    810 Views
    oblivioncthO
    The build was quick and successful with jom -j 8 module-qtbase while normally I haven't had issues skipping the tools with the stable sources I'm guess I'd have needed to change the options passed to init-repository (in addition to -nomake tools) in this case for it to be able to build all modules correctly. I was able to confirm a simple test project using the widgets I need to edit builds and runs correctly after adding the 6.0 build in a kit to Qt Creator. I'll get to fixing QLineEdit and QProgressDialog when I can think straight again. Thanks for dealing with my temporary obliviousness.
  • Progress indicator for slow widget creation

    Solved
    6
    0 Votes
    6 Posts
    757 Views
    Christian EhrlicherC
    @stryga42 said in Progress indicator for slow widget creation: or did I just miss it in the doc? Yes: https://doc.qt.io/qt-5/qimage.html#details "When using QPainter on a QImage, the painting can be performed in another thread than the current GUI thread." And https://doc.qt.io/qt-5/thread-basics.html#gui-thread-and-worker-thread "The Qt GUI must run in this thread. All widgets and several related classes, for example QPixmap, don't work in secondary threads."
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    30 Views
    No one has replied