Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.5k Topics 457.3k Posts
  • Using model indexes

    Solved
    8
    0 Votes
    8 Posts
    1k Views
    K
    Thank you very much, Jon and SGaist, I really appreciate your help and I learned something fundamental :-) I followed your instructions and here is the now working code: (just in case another newbie is stuck with the tutorial "Using model indexes") // myslot.h #ifndef MYSLOT_H #define MYSLOT_H #include <QDebug> #include <QFileSystemModel> #include <QModelIndex> class MySlot : public QObject { Q_OBJECT public: explicit MySlot(QObject *parent) : QObject(parent) {} void setModel(QFileSystemModel* model); public slots: void printDirectory(const QString); private: QFileSystemModel* m_model; }; #endif // MYSLOT_H // myslot.cpp #include "myslot.h" void MySlot::setModel(QFileSystemModel *model) { m_model = model; Object::connect(model,SIGNAL(directoryLoaded(QString)),this,SLOT(printDirectory(QString))); } void MySlot::printDirectory(const QString dir) { QModelIndex parentIndex = m_model->index(dir); int numRows = m_model->rowCount(parentIndex); // qDebug() << numRows; for (int row = 0; row < numRows; ++row) { QModelIndex index = m_model->index(row, 0, parentIndex); QString text = m_model->data(index, Qt::DisplayRole).toString(); // Display the text in a widget. qDebug() << text; } } // main.cpp #include <QApplication> #include <QFileSystemModel> #include <QModelIndex> #include "myslot.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); QFileSystemModel* model = new QFileSystemModel; model->setRootPath(QDir::currentPath()); MySlot* myslot = new MySlot(NULL); myslot->setModel(model); return app.exec(); } Output is a list of all files and folders in the current path. Thanks again for your kind support, I couldn't have done it without your help!
  • How should I include a class?

    Unsolved
    2
    0 Votes
    2 Posts
    1k Views
    beeckscheB
    @cheekibreeki95 In general the header file (.h) includes all the class declarations and the corresponding .cpp file contains all the definitions. When using a Class, you should include the header file. See this How To. I think in your case (without the knowledge of the error), you missed to add the .cpp file in your test project.
  • Use qt from JAVA ? QtJambi for Qt 5.1x

    Unsolved
    2
    0 Votes
    2 Posts
    201 Views
    SGaistS
    Hi, Do you mean in an Android context or more classical Java ?
  • How do I unit test my code?

    Unsolved
    6
    0 Votes
    6 Posts
    2k Views
    SGaistS
    The most simple is to create a .pri file that handles the file part (for example SOURCES and HEADERS variables) and that you can include in both the test and main project .pro files.
  • Qt-Creator: output messages on a per-file-compile basis?

    Unsolved qt creator 4.2 qt 5.8 osx 10.12.6
    5
    0 Votes
    5 Posts
    2k Views
    F
    @aha_1980 said in Qt-Creator: output messages on a per-file-compile basis?: that this will break error parsing Errors??? I don't make errors! lol Yeah, that'd be a real problem. Hm. Well, perhaps it's just impractical on every level with the versions I am using. I really appreciate your taking the time to respond. Cheers!
  • Another noob question - Can't see ui_foo.h at compile

    Solved
    3
    0 Votes
    3 Posts
    268 Views
    U
    Thanks for your help. It turned out to be just plain-old sloppy coding that came from a few places that looked like it was one culprit. I found 'em and fixed 'em. Sorry for wasting your time. Uberlinc.
  • Running external Python 3 script

    Unsolved
    7
    0 Votes
    7 Posts
    706 Views
    aha_1980A
    @saltywaffles which Qt version are you using?
  • Passing Model to a Dialog. View does not get updated properly

    Unsolved
    3
    0 Votes
    3 Posts
    217 Views
    S
    You are right adding mModel->select(); after the mModel->database().commit(); seems to update the View properly to the new data. However this is still weired. Why without it the View adds a row with a !? So it nows theres a new record but it does not know about the new data? record.field("id").setAutoValue(true); was not necessary since id is auto generated so i removed it.
  • How to set the ratio of width and height of the widget?

    Unsolved
    5
    0 Votes
    5 Posts
    421 Views
    M
    It's not work: QSizePolicy sizePolicy1; sizePolicy1.setHeightForWidth(2); ui->labelLogotip->setSizePolicy(sizePolicy1);
  • qaudiooutput Alternative

    Unsolved
    1
    0 Votes
    1 Posts
    142 Views
    No one has replied
  • Any solutions could host the web app developed by Qt(like aws)

    Solved
    18
    0 Votes
    18 Posts
    2k Views
    thamT
    @lorn-potter If I am correct, the sandbox do not allow you to connect with the db like mysql, mariadb directly, the server side need to use another way to communicate with the web app. Anyway to break this limit?
  • Hosting a Static Website on Amazon S3 with Qt for WebAssembly

    Solved
    5
    0 Votes
    5 Posts
    655 Views
    thamT
    @lorn-potter said in Hosting a Static Website on Amazon S3 with Qt for WebAssembly: Yes it is possible and someone has qt examples up: https://s3.eu-west-2.amazonaws.com/wasm-qt-examples/last/index.html Thanks, this post mentioned how to do it. I like the idea of using Qt to create the web app, but this can't be done since it do not support ssl yet(without ssl I can't use the facilities of aws). Questions: Would ssl included in Qt5.14? Any plan to release a prebuild version of Qt for wasm compiled with the flag Os(optimize for size but no speed)? Thanks for your efforts put on Qt for wasm.
  • QNetworkInterface::allInterfaces() produces error messages

    Unsolved
    7
    0 Votes
    7 Posts
    760 Views
    JonBJ
    @mzimmers What I had in mind is there are other deep questions you sometimes have. It's worth it if you can easily re-use the environment all the time, I didn't mean for once-off. And, yes, there are occasions where a problem only manifests in the debugger, or not in the debugger, or only when do/don't compile for debug, and that can get infuriating!
  • Buttons do not react anymore on touch screen after qt upgrade

    Unsolved
    7
    0 Votes
    7 Posts
    516 Views
    JoeCFDJ
    Added a new driver from the manufacturer. No help. It seems a focus issue again since some buttons work and most do not.
  • QTreeView

    Unsolved
    3
    0 Votes
    3 Posts
    294 Views
    T
    Hi Sierdzio, Thanks for the quick help. I think the info is enough for me. Best regards, TinTin
  • 0 Votes
    6 Posts
    869 Views
    lorn.potterL
    I am currently working on refactoring the QNAM backend for webasembly. As well as QTcpSocket and QtWebSocket rework. That said, connecting to https should work. The QNAM backend currently uses XMLHttpRequest, which supports https as is without outside ssl support, as long as the serving certificate is good.
  • Change issues and baby items

    Unsolved
    2
    0 Votes
    2 Posts
    581 Views
    SGaistS
    Hi and welcome to devnet, You need to give more details about what technology you are using. From the looks of it, it could be the graphics view framework but it's only a guess.
  • compiling C# & clr C++?

    Solved
    5
    0 Votes
    5 Posts
    956 Views
    D
    Apparently the answer is: No, there is no "out of the box" method (with no special setup, using qmake) easiest is to just do step 1 and 2 outside of Qt.
  • Add python script to QT program

    Unsolved
    2
    0 Votes
    2 Posts
    499 Views
    Pablo J. RoginaP
    @isan I'd say you have two options: Embed a Python interpreter into the Qt application, see this post (it's Windows related but you'll get the idea) Call the Python script as a QProcess
  • QFormLayout with QVBoxLayout

    Unsolved
    7
    0 Votes
    7 Posts
    750 Views
    L
    @christian-ehrlicher Which widget? The label on the left side doesn't seeem to fill out the complete avaiable height? Otherwise it would has the same height as the labels on the right together, wouldn't it? Why has the left label exactly this height (which by the way stays the same, if you have more spacing in the VBox)