跳到內容

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k 主題 456.4k 貼文
  • Debug output in a C++ library

    Solved
    2
    0 評價
    2 貼文
    220 瀏覽
    S
    @SteMMo said in Debug output in a C++ library: Hi all, I'm developing a pure C++ static library. This library is linked to a Qt application. How can I generate debug messages in the library? I'm developing with VS environment in Windows and VSCode on iOS. I'm trying with cout <<"xyz" and printf() but they are not shown in Debug window.. Thanks! Regards Redirect the stdout somewhere else such as a pipe or even just a file and read from there in the your Qt app. But you could also create an abstration for IO that your library uses and then your Qt host applicadtion can just implement it. Easier.
  • QtRO, How to make repc (.rep) customtype accessible in qml?

    Unsolved
    3
    0 評價
    3 貼文
    202 瀏覽
    M
    @Redman said in QtRO, How to make repc (.rep) customtype accessible in qml?: Q_DECLARE_METATYPE I tried Q_DECLARE_METATYPE, qRegisterMetaType and qmlRegisterType with CustomType and QList<CustomType>. Does not help. When i do this in qml: Connections { target: CustomInterfaceReplica function onListChanged(list) { tabButtonSplit.text = list[0].myProperty } } text shows "undefined". when i call list[0].toString() it shows "QVariant(QList<mynamespace::CustomClass, )"
  • How to use QT creator for developing QT UI applications and using my C++ knowledge

    Unsolved
    4
    0 評價
    4 貼文
    754 瀏覽
    Pl45m4P
    @Venkat123 Like @Bonnie said above, you installed Qt Design Studio. This is solely for modelling (more or less complex) 2D/3D GUIs in QML. So not a QtWidget-application. If you install QtCreator, you will find the IDE for coding in C++
  • What's the best way to parse a huge XML Document?

    Unsolved
    13
    0 評價
    13 貼文
    3k 瀏覽
    S
    Do you need exactly Qt solution? You could check this sample https://redata.dev/smartxml/docs/how-to-parse-xml-into-sql-or-json.html it's not QT, but allow parse big filex
  • QSystemTrayIcon on Windows11

    Solved
    1
    0 評價
    1 貼文
    306 瀏覽
    尚無回覆
  • Ini Files

    Solved
    7
    0 評價
    7 貼文
    420 瀏覽
    S
    You can also provide default values for your settings. In that case you don't even have to include any ini files into qrc in the first place. Provide a path where ini files can be written instead.
  • Qt creator 9.0.1 Header file QtNetwork file not found.

    Unsolved
    14
    0 評價
    14 貼文
    2k 瀏覽
    jsulmJ
    @micha_eleric Please show your current CMakeLists.txt file. Also, you should do complete rebuild after changing CMakeLists.txt
  • qt creator not making a pro file

    Solved
    4
    0 評價
    4 貼文
    309 瀏覽
    Pl45m4P
    @micha_eleric The recommended build system for Qt 6 is CMake, but you can still use QMake (with *.pro file instead of CMakeLists.txt). You need to change your project to QMake Project. https://doc.qt.io/qt-6/qt6-buildsystem.html
  • QT 5.14.1 Debugger broken after MSVC 2017 update

    Unsolved
    2
    0 評價
    2 貼文
    178 瀏覽
    J
    @jabroni I should also add that I've omitted that warning that appears on launch, and instead once w.show() is called, the program stops in the disassembler code section.
  • Problem understanding Signals/Slots

    Solved
    11
    0 評價
    11 貼文
    1k 瀏覽
    E
    @Pl45m4 Problem solved. Thanks to everyone who contributed. I am going to post below the final version of the source code that contains all of the changes that occurred as a result of this topic-thread. Perhaps this example will be useful to another first time user of Qt Signals/Slots. main.cpp #include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); } MainWindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H MainWindow.cpp #include "mainwindow.h" #include "ui_mainwindow.h" #include "myclassa.h" #include "myclassb.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->myView, &MyClassB::mySignal, ui->myLabel, &MyClassA::setPoint); } MainWindow::~MainWindow() { delete ui; } myClassA.h #ifndef MYCLASSA_H #define MYCLASSA_H #include <QLabel> #include <QObject> #include <QPoint> #include <QWidget> class MyClassA : public QLabel { Q_OBJECT public: MyClassA(QWidget *parent = nullptr); ~MyClassA(); public slots: void setPoint (QPoint point); private: QPoint p; }; #endif // MYCLASSA_H MyClassA.cpp #include <QDebug> #include <QLabel> #include <QPoint> #include "myclassA.h" MyClassA::MyClassA(QWidget *parent) : QLabel(parent) { } MyClassA::~MyClassA() { } void MyClassA::setPoint (QPoint point) { qDebug("MyClassA::setPoint"); p = point; } MyClassB.h #ifndef MYCLASSB_H #define MYCLASSB_H #include <QChartView> #include <QMouseEvent> #include <QObject> #include <QPoint> #include <QWidget> class MyClassB : public QChartView { Q_OBJECT public: MyClassB(QWidget *parent = nullptr); ~MyClassB(); signals: void mySignal(QPoint p); protected: void mousePressEvent(QMouseEvent *event) override; }; #endif // MYCLASSB_H MyClassB.cpp #include <QChartView> #include <QMouseEvent> #include <QWidget> #include "myclassB.h" MyClassB::MyClassB(QWidget *parent) : QChartView(parent) { } MyClassB::~MyClassB() { } void MyClassB::mousePressEvent(QMouseEvent* event) { qDebug("MyClassB::mousePressEvent"); QPoint pos = event->pos(); emit mySignal(pos); QChartView::mousePressEvent(event); /* pass-on the event to the base class */ } MainWindow.ui <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>800</width> <height>600</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> <widget class="MyClassB" name="myView"> <property name="geometry"> <rect> <x>160</x> <y>90</y> <width>321</width> <height>281</height> </rect> </property> </widget> <widget class="MyClassA" name="myLabel"> <property name="geometry"> <rect> <x>570</x> <y>190</y> <width>121</width> <height>20</height> </rect> </property> <property name="text"> <string>TextLabel</string> </property> </widget> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>800</width> <height>26</height> </rect> </property> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <customwidgets> <customwidget> <class>MyClassB</class> <extends>QGraphicsView</extends> <header>myclassb.h</header> </customwidget> <customwidget> <class>MyClassA</class> <extends>QLabel</extends> <header location="global">myclassa.h</header> </customwidget> </customwidgets> <resources/> <connections/> </ui>
  • QSerialport readyRead() for measuring revolutions

    Solved
    21
    0 評價
    21 貼文
    2k 瀏覽
    H
    @herrgross got it!!!! in the arduino code the interrupt must be set to RISING instead of HIGH, so it's only sending when the state of the interruptpin c h a n g e s to HIGH attachInterrupt(digitalPinToInterrupt(interruptPin), impuls, RISING); thank you all!!
  • Qt6 application mysteriously links to Qt5 library

    Unsolved
    2
    0 評價
    2 貼文
    146 瀏覽
    JonBJ
    @pixtopo Make sure you are not running ldd on an existing, old executable for Qt5 lying around. Check the timestamp on the file you are examining. From Creator show the complete linker command being run,
  • QScriptEngine memory leak ??

    Unsolved
    6
    0 評價
    6 貼文
    563 瀏覽
    C
    @Martin-Wells said in QScriptEngine memory leak ??: sorry ,Does qt5.15.2 QScriptEngine support let? Evidently not. Not too surprising given that QtScript is long deprecated. Setting the value to undefined (or even an empty string) should give the Javascript garbage collector a chance. Does this scratch your itch? #include <QCoreApplication> #include <QObject> #include <QScriptEngine> #include <QString> #include <QDebug> class Test: public QObject { Q_OBJECT public: Test(QObject *p = nullptr): QObject(p) { } ~Test() { } public slots: QString string() { return QString(10*1024*1024, 'x'); } }; int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QScriptEngine engine; Test *test = new Test(qApp); QScriptValue objectValue = engine.newQObject(test); engine.globalObject().setProperty("Test", objectValue); // At time 0 engine.evaluate("var a = Test.string()"); if(engine.hasUncaughtException()) { qDebug()<<engine.uncaughtException().toString(); } // At some time later qDebug() << "The string length is:" << engine.evaluate("a.length").toNumber(); // and later still engine.evaluate("a = undefined"); if(engine.hasUncaughtException()) { qDebug()<<engine.uncaughtException().toString(); } qDebug() << "The string length is:" << engine.evaluate("a.length").toNumber(); return a.exec(); } #include "main.moc" Why do you want a couple of GB in a Javascript environment? Please use the </> tool in the editor when posting code.
  • QSqlDatabase "Driver not loaded" 🤔🤨

    已移動 Solved
    13
    0 評價
    13 貼文
    1k 瀏覽
    Christian EhrlicherC
    @SEB-MARS As you can see the Mysql plugin is not available - you have to compile it by yourself (blame MySQL, not Qt) as described here.
  • My custom widget does not appear in Qt Designer

    Solved
    8
    0 評價
    8 貼文
    748 瀏覽
    J
    @Christian-Ehrlicher I found the problem: I was placing a debug version of the plugin!! Now that I compiled with release it appears in Qt Designer!! GREAT!! Thanks!!
  • BUMP "Go to slot" issue...

    Unsolved
    2
    0 評價
    2 貼文
    157 瀏覽
    Pl45m4P
    @AnneRanch The first warning says it all... Your copied file is not part of your project. If your current file is in the same directory as your removed file was, simply add the name of your new, copied mainwindow_Bluetooth.cpp to your pro in the cpp section. Edit: The second warning even says that this file is not in your project dir. Better move it to the place where you removed the "old" code file
  • QMainWindow opens in the screen where the mouse is currently in

    Unsolved
    8
    0 評價
    8 貼文
    2k 瀏覽
    G
    It is an error from consumer POV, because it does that even if instructed not to, if originally was instrcted to be open on "main" screen. Worse, using Qt functionality to open Window on particular display is ignored for display "0.0" . Funny, that after this numbering of screens for app changes. If several applications are started, each got screen number 0 as they were launched on. Imagine a multiscreen setup where several windows have to be opened on separate screens. It's a hardware monitoring station, after clicking the icon. I encounter this effect since Qt 4.8.7 that QMainWindow always jumps to the mouse's location, on Xorg only. A "hack" to put start icon on right screen doesn't work because user is able to move cursor faster than app is launched. Neither Windows nor Wayland behavour offer the same, so I supect that X11 window managers are the culprit.
  • Create text display with syntax highlighting

    Unsolved help textarea syntax highligh
    2
    0 評價
    2 貼文
    403 瀏覽
    jsulmJ
    @IGaming73 See https://doc.qt.io/qt-6/qsyntaxhighlighter.html and https://doc.qt.io/qt-6/qtwidgets-richtext-syntaxhighlighter-example.html
  • How to fix strected image label in a layout?

    Unsolved
    8
    0 評價
    8 貼文
    747 瀏覽
    B
    @Rangerguy128 Yes, as @JonB replied above (also need to write codes). But I don't see that makes any sense. When you change scaledcontents to false, it won't keep the image size when it is true, it just show the actual size. So if you are not going to keep the image in its actual size, you need to write codes as @mpergand shows you.
  • 0 評價
    3 貼文
    376 瀏覽
    J
    @Pl45m4 only one thing: which project type should I create in Visual Studio? Qt Designer custom widget? do we need to export the widget? __declspec(dllexport)?? The only problem is the examples are for use in Qt Creator I think while I am in Visual Studio... is there a VS example? How can I find the value of the macros like $$[QT_INSTALL_PLUGINS] and ${INSTALL_EXAMPLEDIR}?