Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.3k Posts
  • Creating a sort of file explorer layout in Qt

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    johnratiusJ
    @JonB Thanks! In the future I will add some sort of editing feature, but for now it will just be viewing.
  • 0 Votes
    8 Posts
    736 Views
    M
    @SGaist I did not say that there is a bug, to be honest I was quiet sure that it is me who is doing something wrong. And yes - I tried Bluetooth Serial Terminal (from Win10 store) and it also takes a few seconds to connect to device as well. I assume it might be the device (it is a custom thing I'd say) that lags on open. Alright, at least I understand now that either I need to move all the stuff to some kind of worker handling QSP on separate thread or accept that there will be a lag on open. Thanks, guys!
  • How to check if no treeitem is selected in the tree view

    Unsolved
    6
    0 Votes
    6 Posts
    953 Views
    Christian EhrlicherC
    @JonB said in How to check if no treeitem is selected in the tree view: Is that subsection new in the docs, in the past I didn't find that explanation? It's already there since some years... :) https://doc.qt.io/archives/qt-4.8/model-view-programming.html
  • 0 Votes
    10 Posts
    3k Views
    Christian EhrlicherC
    I would start with a clean source (make sure there are no generated files) and build dir
  • Does Qt Bluetooth on Windows 10 support AVRCP profile?

    Unsolved
    1
    0 Votes
    1 Posts
    145 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    16 Views
    No one has replied
  • How to listen to QTouchEvent originating from a precision touch pad?

    Unsolved
    3
    0 Votes
    3 Posts
    860 Views
    R
    @jsulm QTouchEvent class has the method *QTouchDevice QTouchEvent::device(). The device type QTouchDevice::TouchPad is supported by QT. So If I understand QTouchEvent documentation correctly, it should be possible. Access to the multitouch data from multi-touch-capable precision touchpads is possible in Windows via a low-level Window's API (e.g. GetRawInputData()). I was guessing/hoping that QTouchEvent was a higher-level, multiplatform solution on top of this.
  • how to append correctly in QT QDomElement?

    Solved
    7
    0 Votes
    7 Posts
    831 Views
    N
    @SGaist @JonB thanks. I have to get previously generated element using QDomNodeList in next iteration and then I can append correctly for each timestamp and device.
  • Execute commands in git bash using QProcess

    Unsolved
    8
    0 Votes
    8 Posts
    2k Views
    JonBJ
    @Adithya said in Execute commands in git bash using QProcess: And yes my intention is to run multiple commands in one session of git bash (That was the reason I was trying via write().) . Then we need a couple of minor modifications your original code: process->start("C:\\Program Files\\Git\\git-bash.exe", QStringList());, or process->start("C:/Program Files/Git/git-bash.exe", QStringList());. No arguments, though you should check the git-bash documentation to see if that wants any special arguments for your case where its input/output is piped. process->write("ls\r\n");. Your order of the CR-LF is the wrong way round. I don't know whether you need the \r, or even if that will upset it and it wants \n only. You might want a "flush" after each write. You call process->readAllStandardOutput() immediately after waitForStarted(), that is/could be too early. You only call waitForReadyRead()/readAll() once. That is (potentially) not enough, output could come back in multiple, separate chunks. You are relying on the output from the bash/command all being flushed from the other end for you to receive it. You had better hope their implementation does that! If you notice only partial data back to you, this could be the reason. You are using the ("nasty") blocking/synchronous waitFor...() calls. If you run into trouble this way/things don't behave as you expect, change over to the asynchronous signals/slots methods of QProcess. Don't forget to close your process/free it!
  • Dynamically get QML model of selected TreeView item

    Unsolved
    1
    0 Votes
    1 Posts
    374 Views
    No one has replied
  • 0 Votes
    3 Posts
    3k Views
    L
    Ahhhh nice, yes The problem was, there has always been a zombie process. That is way I thought the termination did not work properly. What I forgot to do is to also make the QRunnable quit, which remained in the main thread as still running. This is the solution: import tensorflow as tf from sys import exit, argv from multiprocessing import Process, Queue from PyQt5.QtWidgets import QPushButton, QApplication, QHBoxLayout, QWidget, QLabel from PyQt5.QtCore import QRunnable, QObject, pyqtSignal, QThreadPool class Window(QWidget): def __init__(self): QWidget.__init__(self) self.__btn_run = QPushButton("Start") self.__btn_stp = QPushButton("Stop") self.__label = QLabel("Idle") self.__runner = Runner() self.__pool = QThreadPool.globalInstance() self.__btn_run.clicked.connect(self.__run_net) self.__btn_stp.clicked.connect(self.__stp_net) self.__runner.signals.finished.connect(self.__on_finished) self.__btn_stp.setDisabled(True) self.setLayout(QHBoxLayout()) self.layout().addWidget(self.__btn_run) self.layout().addWidget(self.__btn_stp) self.layout().addWidget(self.__label) def __run_net(self): self.__btn_run.setDisabled(True) self.__btn_stp.setEnabled(True) self.__label.setText("Running") self.__pool.start(self.__runner) def __stp_net(self): self.__runner.close() # What to do here? def __on_finished(self): self.__btn_run.setEnabled(True) self.__btn_stp.setDisabled(True) self.__label.setText("Finished") self.__runner = Runner() class Runner(QRunnable): def __init__(self): QRunnable.__init__(self) self.__queue = Queue() self.__net = Mnist(self.__queue) self.signals = RunnerSignal() def run(self): self.__net.start() while True: data = self.__queue.get() if data == NetSignal.finished: self.signals.finished.emit() break def close(self): self.__net.end_process() class RunnerSignal(QObject): finished = pyqtSignal() class Mnist(Process): def __init__(self, queue: Queue): Process.__init__(self) self.__queue = queue def run(self): mnist = tf.keras.datasets.mnist # 28x28 Bilder hangeschriebener Ziffern von 0-9 (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train = tf.keras.utils.normalize(x_train, axis=1) model = tf.keras.models.Sequential() model.add(tf.keras.layers.Flatten()) model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu)) model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu)) model.add(tf.keras.layers.Dense(10, activation=tf.nn.softmax)) model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=['accuracy']) model.fit(x_train, y_train, epochs=8) self.__queue.put(NetSignal.finished) self.__queue.close() def end_process(self): self.terminate() self.__queue.put(NetSignal.finished) class NetSignal: finished = "finished" if __name__ == "__main__": main_thread = QApplication(argv) main_window = Window() main_window.show() exit(main_thread.exec())
  • Application crash on QEventloop::exec() on MacOs

    14
    0 Votes
    14 Posts
    2k Views
    jsulmJ
    @Anj_San You should really learn how to use assynchronous APIs properly instead of making it synchronous with event loops all over the place.
  • QStringLiteral - mingw vs. msvc

    Solved
    3
    0 Votes
    3 Posts
    389 Views
    HoMaH
    @JohanSolo : This is the right track! I found this historic post in a german qt forum which proposes to use a /utf8 switch on the compiler. It is actually /utf-8 - but it works like a charm! I learned that one can put compiler options into the .pro file like this: ... QMAKE_CXXFLAGS = /utf-8 ... So: problem solved! One more note: I think I did not notice this before because my PC was configured with german as the UI / explorer / shell language and I changed to english a while ago. I guess this made a difference, too (besides switching from mingw to msvc
  • QTreeview expandAll windows performance 30 time worse than linux?

    Solved
    4
    0 Votes
    4 Posts
    567 Views
    Seb TurS
    one more lessons learnt - if you use the code quoted above make sure you collapse the QTreeView before expanding it - otherwise if you try to do expand a partially expanded QTreeView it takes ages as the default expandall method
  • convert a mingw project to msvc

    Solved
    9
    0 Votes
    9 Posts
    1k Views
    SGaistS
    There's no other option. Visual Studio can only be installed through Microsoft provided installer.
  • High CPU usage

    Unsolved
    27
    0 Votes
    27 Posts
    6k Views
    JKSHJ
    (Side discussion forked to https://forum.qt.io/topic/119207/relationships-between-qmake-make-nmake-jom-and-the-compiler )
  • append text two different interpretations

    Unsolved
    5
    0 Votes
    5 Posts
    433 Views
    Pl45m4P
    Probably QText means QTextEdit... and it has an append(QString)-function as well :)
  • Force window widget in focus until event occurs

    Solved
    3
    0 Votes
    3 Posts
    552 Views
    johnratiusJ
    @SGaist ah ok. Can I modify my current widget to turn that into a modal dialog, or do i have to re-create my widget to a modal dialog? Edit: Set it up as a QDialog and then after making sure Qt Designer recognized the widget as a QDialog, I checked "modal" in the QDialog settings in Qt Designer and it works great.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    10 Views
    No one has replied
  • I have trouble plotting multiple datapoints using QCPCurve

    Unsolved
    3
    0 Votes
    3 Posts
    534 Views
    M
    Thank you for the information. I posted a thread there too now. If its ok I would leave this thread in case anyone can help..