Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • Writing a json file!

    Solved
    5
    0 Votes
    5 Posts
    496 Views
    K
    got it working :) thanks @JonB and @SGaist QJsonObject studiolights; studiolights.insert("IPA", "studiolights"); studiolights.insert("Icon", "fa_bolt"); studiolights.insert("Name", "Studio Lights"); studiolights.insert("Status", "online"); studiolights.insert("Type", "Strip"); studiolights.insert("UVLights", "false"); QJsonArray devices; devices.append(studiolights); QJsonObject obj; obj["Device"] = devices; QJsonDocument jsonDoc; jsonDoc.setObject(obj); file.write(jsonDoc.toJson()); file.close();
  • Unable to use MSVC 2019 compiler successfully in Qt Creator (C++ / QWidgets app)

    Unsolved
    10
    0 Votes
    10 Posts
    2k Views
    SGaistS
    Did you install the full Visual Studio to just the C++ tools Yes, the icon looks nice.
  • Save a .rtf file formatting the text in a QTextEdit

    Solved
    12
    0 Votes
    12 Posts
    1k Views
    H
    @HenkCoder oh nevermind, I managed to understand. Thank you for your help.
  • Hide Minimize and Maximize buttons of the main window - Kubuntu 20.10

    Unsolved
    6
    0 Votes
    6 Posts
    5k Views
    JonBJ
    @stretchthebits The ones I told you in my previous post. Just as per their names imply. Note they are "hints". The native windowing system may ignore them.
  • QSettings array of values (rather than groups)

    Unsolved
    9
    0 Votes
    9 Posts
    1k Views
    M
    @Pl45m4 Ah, alright. I will probably overload QDataStream& operator<< and operator>> for QVector<T> where it just puts the size and then the items.
  • How to convert string to float

    Unsolved
    3
    0 Votes
    3 Posts
    650 Views
    Kent-DorfmanK
    std::istringstream there are tons of examples online.
  • Design tips on writing on translator like application using Qt?

    Unsolved
    2
    0 Votes
    2 Posts
    126 Views
    SGaistS
    Hi and welcome to devnet, I don't see any use of model in what you suggest here. You basically call an API on press of a button, so I do not see the need of model view. You might want to consider doing some caching to avoid spamming the API with request already done though.
  • QT6 QAudioSource and ASIO drivers?

    Solved
    2
    0 Votes
    2 Posts
    535 Views
    SGaistS
    Hi, QtMultimedia uses the system multimedia framework. For something more specialised, you will have to use something like PortAudio which is pretty easy to integrate with Qt itself.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    13 Views
    No one has replied
  • Send Email ?

    Unsolved
    3
    0 Votes
    3 Posts
    226 Views
    V
    try QT += network to add your pro file
  • Change default run configuration in Qt Creator

    Unsolved
    1
    0 Votes
    1 Posts
    487 Views
    No one has replied
  • MainWindow’ does not name a type;

    Moved Unsolved
    9
    0 Votes
    9 Posts
    875 Views
    Chris KawaC
    I wonder if I can copy your flowchart and import them to www.draw.io Sorry, normally you can share the graphs themselves in one of the graph formats supported, but I just exported them as images and didn't kept originals. Shouldn't be too hard to recreate them though if you want to. It took me like 5 minutes to make them. Just a note so you don't get the wrong impressions. These charts are only meant to represent dependencies, not which code calls what and whether to use connections or something else. You can actually implement the bad and the good model using the same tools, it's just a matter of arranging them. For example, this is a simple one way dependency: struct Data { ... }; class Dialog { public slots: void doSomething(const Data& data) { emit somethingHappened(data); } signals: void somethingHappened(const Data& data); }; class MainWindow { MainWindow() { connect(&dialog, &Dialog::somethingHappened, this, &MainWindow::doSomething); Data data; dialog.doSomething(data); } void doSomething(const Data& data) {} Dialog dialog; }; If you delete Dialog then MainWindow won't compile, but you can delete MainWindow and Dialog works without any changes. This is a one way dependency that would be represented like this: [image: y4md6igANcwE44KUV8o4S6AifBgrUkE2QK-OAXWmMWj4tnoIJ9TLbE892ZiKdOES8CvwlfwA8At_GTRjUTmFCPIziNvIIzM8chWGZGB2Tx-p2HaWnOsEVuZZoSUbbQtGVRnxpbBbO4wGuU5w1jSj_sWyUJhNkVBzTDJ6VhV--X7nNJJKnQAaZS7zLlNl7x3qBq1?width=321&height=31&cropmode=none] But you can achieve exactly the same functionality with bad dependency management like this: struct Data { ... }; class MainWindow; MainWindow* global; class Dialog { Dialog() { connect(this, &Dialog::somethingHappened, global, &MainWindow::doSomething); } public slots: void doSomething() { emit somethingHappened(global->data); } signals: void somethingHappened(const Data& data); }; class MainWindow { MainWindow() { global = this; dialog.doSomething(); } void doSomething(const Data& data) {} Data data; Dialog dialog; }; It does exactly the same but creates circular dependency. You can't delete one class without at least modifying the other. You also have a class declaration chicken and egg problem so it's actually hard to make this code compile. This would be the two way, or, in case of more classes, a circular dependency: [image: y4mu2-eLWOianc8v1xQbC2rh_c3NLbzZ1KJ5f81CWTXNqae4alLQzw_u4aPYeL4g8tRj0AXRBHykeQ8WxX8FOumRMi1RS7QwaITh-ulfKClbl6X0RzwrRQPqUg6ubRbSYgjt8pCQwzLIgp5CDu9oTyjoEdFl1NzaemmEMS0zhsOPn4KeqDANe95yO_JC8ht-lpA?width=321&height=31&cropmode=none] But, as you can hopefully see, it doesn't have anything to do with oop or any other buzz word. Both use the same tools - classes, signals and connects. It's just a matter of code layout and sitting with a pencil and a piece of paper to draw up dependencies before starting to code.
  • how get filtered data from QSortFilterProxyModel ?

    Solved
    4
    0 Votes
    4 Posts
    3k Views
    paghsaP
    @JonB oh god it was dead simple anyways thanks a lot ;) for other people who may face to this problem you should use proxy->index() and play with it QModelIndex index = proxyModel->index(row , column , parentIndex); int rowCount = proxy->rowCount(proxyModel); // it gives you the count of rows qInfo() << proxy->data(index , sourceModel::enum); // it prints the corresponding data in my case i have a treeModel and have to search all filtered rows for particular value.
  • 2 Different fonts in a QTextEdit

    Solved
    5
    0 Votes
    5 Posts
    703 Views
    H
    @JonB Thank you, I resolved this thing using setCurrentFont().
  • Common way to selecting correct slot

    Unsolved
    22
    0 Votes
    22 Posts
    2k Views
    qtprogrammer123Q
    @qtprogrammer123 said in Common way to selecting correct slot: Hi, that solution is ok? sendData & readData are connected to serial. Im not run it, just wrote fust sample #ifndef SB_H #define SB_H #include <QObject> class SerialBroadcaster : public QObject { Q_OBJECT public: explicit SerialBroadcaster(QObject *parent = nullptr); public slots: void send(const QByteArray &data, int reciver){ this->reciver = reciver; emit sendData(data); } void readData(const QByteArray &data){ if(reciver == 1) respondeToConsole(data); else if(reciver == 2) respondToCommand(data); reciver = 0; } signals: void sendData(const QByteArray &data); void respondeToConsole(const QByteArray &data); void respondToCommand(const QByteArray &data); private: int reciver = 0; }; #endif // TCPREADER_H +erros signal, and probably others that I don't think about right now
  • undefined reference to `__imp_ WSASend / WSARec / WSASocketW

    Solved
    5
    0 Votes
    5 Posts
    3k Views
    AxelViennaA
    @JonB said Hi Jon, thank you so much! -lws2_32 did the trick and the whole show is now compiling and running. You get wiser by the day.
  • Qcalendar in the same window as the main ui

    Unsolved qcalendarwidget general problem
    2
    0 Votes
    2 Posts
    346 Views
    JonBJ
    @poggers What do you mean by this "separate window"? Are you talking about the popup, see dateEditEnabled, also Using a Pop-up Calendar Widget? Or something else?
  • keypressed

    Unsolved
    4
    0 Votes
    4 Posts
    252 Views
    SGaistS
    Then create a new QKeyPressEvent and send it. But still, you should explain your use case. As a user, pressing one key and having a different one handled is going to feel very awkward.
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    7 Views
  • 0 Votes
    4 Posts
    409 Views
    SGaistS
    @Qnut said in Universal way to parse QString with non-fixed date-time formats for QDateTime conversion: COleDateTime::ParseDateTime Checking the documentation of that method, it does not seem to be as universal as you describe it. It also uses the system locale by default.