Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • Why "standard " Linux sleep(x) - as defined in uinstd.h does not work as expected ?

    Solved
    12
    0 Votes
    12 Posts
    818 Views
    JonBJ
    @AnneRanch The caller can set off multiple QTimer::singleshot()s (it's static) with different delays in advance, calling the same or different slots: QTimer::singleShot(5 * 1000, this, &CCC_DiscoverDevice::helloWave); QTimer::singleShot(10 * 1000, this, &CCC_DiscoverDevice::helloWave); QTimer::singleShot(15 * 1000, this, &CCC_DiscoverDevice::differentWave); Or, the slot can set off a new one, calling the same or different slot: void CCC_DiscoverDevice::helloWave() { ui->plainTextEdit_4->setPlainText(...); QTimer::singleShot(15 * 1000, this, &CCC_DiscoverDevice::differentWave); // if you call the same slot like next line, it will keep repeating, as this line will be hit again next time // you'll need some `if (...)` if you no longer wish to keep repeating QTimer::singleShot(15 * 1000, this, &CCC_DiscoverDevice::helloWave); } Or, don't use singleShot(). QTimer is a repeating timer: timerDelay->callOnTimeout(&CCC_DiscoverDevice::helloWave); timer->start(5000); calls the same slot every 5 seconds. Call timer->stop() to switch it off.
  • Decode QString str(R"RX(...)RX") and explain what it is

    Unsolved
    5
    0 Votes
    5 Posts
    2k Views
    SGaistS
    Hi, Just in case, Qt provides a helper tool to help you write your regexps and test them.
  • How to check if the tree view is currently scrolling

    Unsolved
    4
    0 Votes
    4 Posts
    350 Views
    mrjjM
    @summit Hi you get to the scrollbar like this verticalScrollBar() (inside your class) so you connect its valuechanged signal to your own function. https://doc.qt.io/qt-5.15/qscrollbar.html#details or maybe sliderMoved() depending on what you want.
  • How to prevent widget from inheriting parent CSS ?

    Solved
    2
    0 Votes
    2 Posts
    333 Views
    SPlattenS
    @SPlatten , Fixed I had a bug which was stripping off the QFrame { part of the CSS, with that fixed its now ok.
  • Formal letter with QTextDocument

    Solved
    6
    0 Votes
    6 Posts
    546 Views
    mrjjM
    @HoMa Hi Well the SVG way is most useful if you got a very detailed page and you don't have to adjust positions according to content size. Anyhow, the QPrinterEasy sounds exactly what you want so I hope it will just compile in newer Qt versions. Good luck.
  • How to delete dots from QListWidget?

    Solved
    5
    0 Votes
    5 Posts
    644 Views
    Christian EhrlicherC
    @TomNow99 said in How to delete dots from QListWidget?: why when I don't set css - everything is ok? Because your default style maybe does not draw a focus rect? Don't know your default style. For css another style is used due to: "Style sheets are applied on top of the current widget style, meaning that your applications will look as native as possible, but any style sheet constraints will be taken into consideration." (https://doc.qt.io/qt-5/stylesheet.html)
  • This topic is deleted!

    Unsolved
    6
    0 Votes
    6 Posts
    29 Views
  • why my icon has gone?

    Solved
    5
    -1 Votes
    5 Posts
    556 Views
    W
    @Bonnie thank your solution that helping me resolve this problem.
  • Creating a 32x32 "Matrix" of dynamicaly added buttons into a layout!

    Solved
    3
    0 Votes
    3 Posts
    306 Views
    K
    @SGaist i see that now xD ...
  • Create a colormap spectrum in Qt

    Unsolved
    3
    0 Votes
    3 Posts
    595 Views
    M
    In my researches, I found this example https://doc.qt.io/qt-5/qtgui-openglwindow-example.html a triangle with normalized coordinates between [-1,1] (obviously because of opengl, iirc) and a color for each corner is drawn, and color is interpolated in between. can I use the same technic with these points? something like below: [image: abc2d183-e97d-4e04-a35e-8fb518397405.png] with triangulating points and feed them to opengl, I want to have an interpolated and colored surface
  • Program freeze when try to get MD5 of files

    Unsolved
    31
    0 Votes
    31 Posts
    3k Views
    S
    @SGaist thanks my code is it for know it working good without freeze gui in term of coding this code is standard? mainwindow2.cpp MainWindow2::MainWindow2(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow2) { ui->setupUi(this); connect(ui->pushButton_3, &QPushButton::clicked, this, &MainWindow2::MD5_thread_1); future = new QFuture<QString>; watcher1 = new QFutureWatcher<QString>; watcher2 = new QFutureWatcher<QString>; watcher3 = new QFutureWatcher<QString>; connect(watcher1, SIGNAL(finished()), this, SLOT(MD5_thread_2())); connect(watcher2, SIGNAL(finished()), this, SLOT(MD5_thread_3())); connect(watcher3, SIGNAL(finished()), this, SLOT(core_install())); //some other code } void MainWindow2::MD5_thread_1() { ui->pushButton->setEnabled(false); ui->pushButton->setText("procces started"); ui->pushButton->setStyleSheet("QPushButton { color : white; background-color: rgb(73, 80, 93); }"); ui->label->setText("checking"); ui->label_2->setText("checking"); ui->label_3->setText("checking"); ui->label_4->setText("checking"); ui->label_5->setText("checking"); ui->label_6->setText("checking"); ui->label_7->setText("checking"); ui->label_8->setText("checking"); ui->label_14->setText("waiting for end of check"); ui->progressBar->setRange(0, 100); ui->progressBar_2->setRange(0, 100); ui->progressBar->setValue(0); ui->progressBar_2->setValue(0); //file pak33 QString loc33 = "/SMG0/editor.pak"; *future= QtConcurrent::run(QThreadPool::globalInstance(), Md5_gen, loc33); watcher1->setFuture(*future); } void MainWindow2::MD5_thread_2() { QString pakchunk33 = future->result(); qDebug() << pakchunk33; if (pakchunk33 == "f7002d4419cd235a87746715ba6fb2ea") { qDebug() << "OK"; file_ok++; ui->label_8->setText("OK"); ui->label_8->setStyleSheet("QLabel { color : green; }"); } else if (pakchunk33 == "nofile") { qDebug() << "no file found"; ui->label_8->setText("not found"); ui->label_8->setStyleSheet("QLabel { color : red; }"); } else { qDebug() << "file is diffrent"; ui->label_8->setText("wrong"); ui->label_8->setStyleSheet("QLabel { color : red; }"); } ui->progressBar->setValue(12); //file pak34 QString loc34 = "/SMG0/2Editor.pak"; *future = QtConcurrent::run(QThreadPool::globalInstance(), Md5_gen, loc34); watcher2->setFuture(*future); } void MainWindow2::MD5_thread_3() { QString pakchunk34 = future->result(); qDebug() << pakchunk34; if (pakchunk34 == "64c77598586b6c3cb60beed0b0750620") { qDebug() << "OK"; file_ok++; ui->label->setText("OK"); ui->label->setStyleSheet("QLabel { color : green; }"); } else if (pakchunk34 == "nofile") { qDebug() << "no file found"; ui->label->setText("not found"); ui->label->setStyleSheet("QLabel { color : red; }"); } else { qDebug() << "file is diffrent"; ui->label->setText("wrong"); ui->label->setStyleSheet("QLabel { color : red; }"); } ui->progressBar->setValue(25); //file pak35 QString loc35 = "/SMG0/3Editor.pak"; *future = QtConcurrent::run(QThreadPool::globalInstance(), Md5_gen, loc35); watcher3->setFuture(*future); } void MainWindow2::core_install { QString pakchunk35 = future->result(); qDebug() << pakchunk40; if (pakchunk40 == "49e0440340044f424caeb82bade1301f") { qDebug() << "OK"; file_ok++; ui->label_2->setText("OK"); ui->label_2->setStyleSheet("QLabel { color : green; }"); } else if (pakchunk40 == "nofile") { qDebug() << "no file found"; ui->label_2->setText("not found"); ui->label_2->setStyleSheet("QLabel { color : red; }"); } else { qDebug() << "file is diffrent"; ui->label_2->setText("wrong"); ui->label_2->setStyleSheet("QLabel { color : red; }"); } ui->progressBar->setValue(100); //check if game is okey or not if (file_ok == 8) { ui->label_14->setText("O"); ui->label_14->setStyleSheet("QLabel { color : green; }"); } else { ui->label_14->setText("X"); ui->label_14->setStyleSheet("QLabel { color : red; }"); } } mainwindow2.h #ifndef MAINWINDOW2_H #define MAINWINDOW2_H #include <QMainWindow> #include <QtConcurrentRun> #include <QFuture> #include <QFutureWatcher> #include <QThread> #include <QThreadPool> #include "user_def.h" namespace Ui { class MainWindow2; } class MainWindow2 : public QMainWindow { Q_OBJECT public: explicit MainWindow2(QWidget *parent = nullptr); ~MainWindow2(); public slots: void MD5_thread_1(); void MD5_thread_2(); void MD5_thread_3(); void core_install(); private slots: void on_pushButton_clicked(); void on_pushButton_2_clicked(); void on_radioButton_2_clicked(); void on_radioButton_4_clicked(); void on_radioButton_3_clicked(); void on_radioButton_clicked(); private: Ui::MainWindow2 *ui; QFutureWatcher<QString> *watcher1; QFutureWatcher<QString> *watcher2; QFutureWatcher<QString> *watcher3; QFuture<QString> *future; int file_ok = 0; }; #endif // MAINWINDOW2_H
  • Multiple Animations with different start times

    Unsolved
    2
    1 Votes
    2 Posts
    323 Views
    P
    all good, I can delay animations with QPauseAnimation...
  • Is it the proper way to change QWidgets in QGridLayout

    Unsolved
    2
    0 Votes
    2 Posts
    334 Views
    JonBJ
    @TomNow99 I have no idea whether it would be "better" or "worse" then your way of QGridLayout and stretching/shtinking column widths. But this could (presumably) all be implemented via QHBoxLayouts & QVBoxLayouts. The whole thing is as per #2: is hbox, with 3 vboxes; middle one is 2 vboxes, with top cell being 2 hboxes. Then #1 is hide/show some widgets/boxes: the right-hand vbox is empty, and so is the right-hand one in the vbox in the middle. My explanation might not be great, but you should get the drift. That allows the boxes to flow to fill the layouts. Whether it's beneficial I don't know. I just come from HTML where in this kind of alyout divs (Q(H|V)BoxLayout) are good and tables (QGridLayout) are devil-spawn ;-)
  • Dynamically created buttons and connecting signal to slot

    Solved
    13
    0 Votes
    13 Posts
    2k Views
    mrjjM
    @Kris-Revi Yes exactly.
  • Why does QMap together with QtConcurrent::blockingMapped() not works?

    Solved
    7
    0 Votes
    7 Posts
    586 Views
    PowerNowP
    @Christian-Ehrlicher Yea, it seems so that QMap is not a sequence. Thxs!
  • Set validator to custom QAbstractItemModel (tree model)

    Solved
    3
    0 Votes
    3 Posts
    590 Views
    Please_Help_me_DP
    @VRonin thank you! I've found an example here I've spent one day to understand why above example didn't work for me (QIntValidator didn't restrict my input even if I write letter). So here is some information for those who encounter the same problem I noticed one thing. Let's suppose that we have QLineEdit with set QIntValidator and this line by default has some statement like abc. When we try to add any symbol/character to this line then QIntValidator doesn't block our input and we are allowed to write it. To make Validator work we need firstly remove all symbols that are not allowed by the validator and only then validator starts to work (we will be able to write only integer).
  • Populating a Grid with buttons but having problems

    Solved
    2
    0 Votes
    2 Posts
    433 Views
    JonBJ
    @Kris-Revi To undo your previous addWidget(button)s, you need to take the button out of the layout and delete it cleanly. One way is to use [override virtual]QLayoutItem *QGridLayout::takeAt(int index) with the code like in https://doc.qt.io/qt-5/qlayout.html#takeAt: QLayoutItem *child; while ((child = layout->takeAt(0)) != nullptr) { ... delete child->widget(); // delete the widget delete child; // delete the layout item } Note that your proposed loop through the images found in the folder to do the deleting of the buttons with images previously created is not a good approach: if an image file has been deleted you will not meet it in that new loop now to delete it, you want to iterate through the widgets already in the layout doing deletions as per my suggestion. Of course it's not very efficient if you have to recreate all the old items in response to "everytime i upload a new image i want to run this function ", if you want that "nicer" you'd have to add/remove only the changed icons in the folder, but that's up to you....
  • Send QVector via socket QString?

    Solved
    18
    0 Votes
    18 Posts
    1k Views
    JonBJ
    @Kris-Revi LOL. If that's what floats your "sexy" boat, that is good :D The point anyway is that it is via QJsonDocument::toJson() that you can transform your data into something suitable to send.
  • How could I improve the QObjectPicker accuracy?

    Unsolved qt3d
    2
    0 Votes
    2 Posts
    529 Views
    G
    @jimfar Hi, I have the same problem in my Qt application... Any solutions?
  • Building qt 5.15.1 static on windows using mingw

    Unsolved
    9
    0 Votes
    9 Posts
    1k Views
    R
    ok fixed that with the following line configure.bat -release -static -opensource -confirm-license -static-runtime -qt-zlib -qt-libjpeg -qt-tiff -qt-webp -qt-libpng -qt-freetype -qt-pcre -qt-harfbuzz -gui -widgets -no-pch -opengl desktop -platform win32-g++ -prefix "C:\Qt\QT-Static-2" -skip webengine -nomake tools -nomake tests -nomake examples -openssl-linked OPENSSL_INCDIR="C:\OpenSSL-Win64\include" OPENSSL_LIBDIR="C:\OpenSSL-Win64\lib" OPENSSL_LIBS="-lWs2_32 -lGdi32 -lAdvapi32 -lCrypt32 -lUser32" OPENSSL_LIBS_DEBUG="-lssl -lcrypto" OPENSSL_LIBS_RELEASE="-lssl -lcrypto" issue is now it wont find the -lssl and -lcrypto when building the app even thoe it is there