Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.6k Posts
  • Get the index of an item from QTreeView

    Unsolved
    4
    0 Votes
    4 Posts
    1k Views
    JonBJ
    @vijaychsk You could keep a "lookup table/map" as @Kent-Dorfman says. But potentially that could be "costly" to maintain, especially if the tree is large/deep. There are two ways you can do it just from the information already held in the tree model. Do like QFileSystemModel does it. It defines a role QFileSystemModel::FilePathRole Qt::UserRole + 1. That role returns the full file path from each node/leaf. You can then search for this full path (e.g. via @jeremy_k's QAbstractItemModel::match()). This is simple but "expensive": the tree does a lot of looking back up at parentage (unless you do some extra work) to generate each item's full path to compare. Just look down the tree for each element in turn from the desired path. For example, if looking for /a/b/c, first find a at top-level, then b among its children, and finally c among b's children. You could do that easily yourself from model's nodes' children, or maybe from QAbstractItemModel::match() without the Qt::MatchRecursive flag being set in Qt::MatchFlags flags.
  • QMqtt5 extracting response topic from received message

    Unsolved mqtt
    1
    0 Votes
    1 Posts
    314 Views
    No one has replied
  • Install old Qt-5.9.9 opensource

    Moved Unsolved
    4
    0 Votes
    4 Posts
    1k Views
    J
    @JNBJNB Since you mentioned that you want to use Qt-5.9.9 for building a software in your public laboratory, you should select the open source license option when prompted by the installation tool. The open source license allows you to use, modify and distribute the software freely in accordance with the terms of the license agreement. If you are unsure about which license to choose, you can refer to the Qt licensing page for more information: https://www.qt.io/licensing/ I hope this helps. Let me know if you have any further questions!
  • Using an external .json file for configuration

    Unsolved
    13
    0 Votes
    13 Posts
    3k Views
    Christian EhrlicherC
    @Clone45 said in Using an external .json file for configuration: after I added the resource files to qt_add_executable set(CMAKE_AUTORCC ON) Yes, this is also possible because you enabled AUTORCC.
  • Connection timed out when using QTcpSocket

    Unsolved
    7
    0 Votes
    7 Posts
    669 Views
    N
    @Kent-Dorfman even if I open the required ports to the apache server in my router?
  • New type of SIGNAL/SLOT connection issue

    Solved
    3
    0 Votes
    3 Posts
    267 Views
    K
    @mpergand you are right, I tried with qOverload<void> and since now only for signal parameter. Thank you!
  • QWebEngineView Class

    Unsolved
    8
    0 Votes
    8 Posts
    529 Views
    Christian EhrlicherC
    @Kris-Revi said in QWebEngineView Class: but in Qt Maintenance i don't see MSVC You can select the desired Qt library (MinGW or MSVC) in there. Don't know what this has to do with Visual Studio Code (which is an IDE) though.
  • Have troubles with QCommandLineParser

    Solved
    4
    0 Votes
    4 Posts
    1k Views
    JonBJ
    @tubbadu There must/ought to be a way (putenv(SOME_ENV_VAR)?) of switching off Qt grabbing its own arguments? Which you might want here? Else Qt apps could never see generic arguments, maybe this is a QGuiApplication thing not QCoreApplication?
  • QComboBox doesn't works change event

    Solved
    12
    0 Votes
    12 Posts
    2k Views
    Christian EhrlicherC
    @JonB Maybe a linker error (vtable) - don't know.
  • QAction Icon not displaying

    Solved
    3
    0 Votes
    3 Posts
    219 Views
    PerdrixP
    @Christian-Ehrlicher Bingo! I had set it in Designer but it had picked up the filesystem file location not the location of the resource... Now fixed. Thank you
  • Qt6.5.0 and ibus (Ubuntu)

    Unsolved
    28
    1 Votes
    28 Posts
    13k Views
    F
    I googled around and could not find a solution. Then I switched to Wayland and the code does not crash anymore. Has Qt6.5 switched to Wayland completely? However, the ibus message is still there, but does not matter.
  • Qt Color Wheel

    Unsolved
    3
    0 Votes
    3 Posts
    543 Views
    Pl45m4P
    @Kris-Revi Something like this? https://github.com/mamontov-cpp/qt-palette-color-picker
  • Using jpeg2000 with QT

    Solved
    5
    0 Votes
    5 Posts
    602 Views
    M
    @Abderrahmene_Rayene Wow. I din't know that. Thanks a lot
  • fonts not loaded on certain Windows 10 systems

    Unsolved
    1
    0 Votes
    1 Posts
    113 Views
    No one has replied
  • how to get a char in index from QString?

    Solved
    2
    0 Votes
    2 Posts
    218 Views
    JonBJ
    @RuWex What about searching the QString doc for index and finding indexOf()?
  • Convert SIGNAL to new Signal Format

    Solved
    11
    0 Votes
    11 Posts
    2k Views
    JonBJ
    @mjs513 That pyqtSignal(...) is a PyQt-ism. I think you have to use it any time you want to define your own signal. However, none of this relates to your earlier problem of self.connect(self.serialPortEdit, SIGNAL("returnPressed()"), self.connectButton, SIGNAL("clicked()")) I have now had a chance to try this. On my PyQt 5.15.6 the equivalent of the attempted self.serialPortEdit.returnPressed.connect(self.connectButton.clicked) gives an error message like yours but with a bit more detail: QObject::connect: Incompatible sender/receiver arguments QLineEdit::returnPressed() --> QPushButton::clicked(bool) Traceback (most recent call last): File "/home/jon/PyQt5/testconnect1.py", line 20, in <module> window() File "/home/jon/PyQt5/testconnect1.py", line 14, in window le.returnPressed.connect(pb.clicked) TypeError: connect() failed between returnPressed() and clicked() You can see from QLineEdit::returnPressed() --> QPushButton::clicked(bool) it is saying returnPressed() takes no argument but QPushButton::clicked(bool) does (a bool for whether any checkbox on the button is checked). Which is what I assumed the problem would be. Although this defaults to False if not passed, it is still enough to make those two signals' signatures incompatible, you cannot directly get returnPressed() signal to call clicked(bool). In principle this is where you would use the lambda syntax I mentioned for the slot, like one of these: self.serialPortEdit.returnPressed.connect( lambda: self.connectButton.clicked() ) self.serialPortEdit.returnPressed.connect( lambda: self.connectButton.clicked(False) ) But this results in le.returnPressed.connect(lambda: pb.clicked()) TypeError: native Qt signal is not callable PyQt apparently does not like us directly calling QPushButton.clicked(), because it is a "native Qt signal". We would be allowed to do this in C++. I don't know how you would get to call it from PyQt. [Following is unnecessary, see UPDATE section below.] The only way I know to do this now would be: self.serialPortEdit.returnPressed.connect( lambda: self.connectButton.click() ) I still use a lambda, but I call QPushButton.click() which is a slot to "emulate" a click rather than calling the QPushButton.clicked() signal which Qt emits. In this case I could also skip the lambda (because their arguments --- none --- are compatible) and attach this slot directly to the signal: self.serialPortEdit.returnPressed.connect( self.connectButton.click ) UPDATE OK, I get why, PyQt5 never lets you call a signal method directly, you always have to use emit(). So to use clicked() signal directly and not have to use the click() slot (which we are lucky even exists), you should use: self.serialPortEdit.returnPressed.connect( lambda: self.connectButton.clicked.emit() )
  • QML module not found (QtQuick.Controls)

    Locked Unsolved qtquick controls qml
    2
    0 Votes
    2 Posts
    537 Views
    SGaistS
    Hi, Please don't post the exact same question in multiple sub-forum. One is enough. When needed, it can be moved. Closing this one as duplicate from this thread since it's in the correct sub-forum.
  • How to use the QRemoteObjet class to share data between processes?

    Unsolved
    11
    0 Votes
    11 Posts
    893 Views
    J
    @Cesar i fixed it, but i continue getting the same error.
  • Moc compilation error

    Unsolved
    7
    0 Votes
    7 Posts
    2k Views
    Christian EhrlicherC
    @Ylvy said in Moc compilation error: And when you need more than one argument? A property does need exactly one element as written in the documentation - otherwise it's not a property. So either don't define it as property or only pass one argument.
  • Can't get QMap value using a <double> key

    Solved
    5
    0 Votes
    5 Posts
    383 Views
    JonBJ
    @Atr0p0s said in Can't get QMap value using a <double> key: I guess it's better not to use double type for keys :) You have to be careful with doubles. As a great author once said [paraphrased]: "All [well, some] doubles are equal, and some doubles are more equal than others" ;-)