Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • How to use Undo-Redo functionality in Schematic feature ?

    Unsolved
    12
    0 Votes
    12 Posts
    1k Views
    S
    From the last code you have shown it looks like you don't want the regular undo/redo feature. Here is the regular idea of a QUndoCommand: When the user does an action you create a new command and push it onto the QUndoStack. Normally, the actions are undone through the undo stack. This might be through a shortcut (Ctrl+Z) or the menu. The QUndoCommand has both a redo() and an undo() function. When you push the command on the stack it will execute the redo function. When you undo the stack, you don't create a new command, but the undo stack will just execute the undo function of the same command that is already stored on the stack. And the stack does not drop your command immediately, so you could actually undo the undo operation (i.e. the redo). It allows you to redo the exact same command which is stored on the undo stack. I am not sure if your double click action would fit right in to the undo/redo functionality. It is probably not what a user expects. The only way this could work out is if you have both an expand undo command and a collapse undo command. So, if you double click to expand you push the expand undo command to the undo stack. The use could now undo to collapse again and after redo to expand again. However, if the user double clicks again you would push a collapse undo command on the undo stack. What that means is that your implementation for redo() in your expand undo command is the same as the undo() in your collapse undo command and vice versa. Before you write any undo commands you should figure out what to do when double clicking to expand or collapse. If this code works without first creating an undo command you can then put the code for expansion into the redo() function and the code for collapse into the undo() function of your expand undo command (and the other way around for your collapse command -- you might want to have ExpandCollapseUndoCommand which receives an additional boolean (or better an enum) to choose between expansion or collapse). If you can't figure out what to do without the undo command you will not be able to write the undo command.
  • Qt4 to Qt5 MD5 Hash Compatibility

    Solved
    7
    0 Votes
    7 Posts
    555 Views
    M
    Just to close this out - problem solved. The issue was not the MD5 hash calculation. It was the fact that Qt4 and Qt5 differ when using this constructor QByteArray ba(QString &); The conversion did not produce the same array - which was used to calculate the hash. This gives the appearance of "working" if the QString is Ascii or straight conversion to Latin1. The problem manifested when the QString was a unicode string for a non-Latin base language! Solution: QByteArray ba(QString value.toUtf()) - before calculating/verifying the hash! Thanks for all the suggestions!
  • Insanely slow updating of pyqtgraph when changing colorbar bounds

    Unsolved
    3
    0 Votes
    3 Posts
    556 Views
    K
    @ChrisW67 good point on setting it once. I posted on the pyqtgraph google group, thanks for the suggestion!
  • Difference with QFileDialog between static and dynamic build on Xubuntu

    Solved
    2
    0 Votes
    2 Posts
    220 Views
    F
    For anyone else encountering this issue, what was required in the CMakeLists.txt was qt_import_plugins(application-gui INCLUDE Qt::QGtk3ThemePlugin) as well as making sure the following packages were installed when building the static libraries and making sure to do a completely clean build after installing them. sudo apt-get install libgtk-3-dev libglib2.0-dev
  • Change how selected a QGraphicsItem object is displayed

    Solved
    2
    0 Votes
    2 Posts
    367 Views
    Pl45m4P
    @Michael-Lehn said in Change how selected a QGraphicsItem object is displayed: My implementation works but I wonder whether it is the "right thing" ... Should be fine since you only change the style. The selection behavior should not be affected
  • how qt tab switch focus

    Unsolved
    2
    0 Votes
    2 Posts
    151 Views
    Christian EhrlicherC
    You can set the focus with QWidget::setFocus() but why do you want to confuse the user?
  • [Solved] First menu on menubar not activating when moused over

    23
    0 Votes
    23 Posts
    17k Views
    B
    @blane245 Thanks, lost a lot of time without figuring this out and then I found this useful thread.
  • TreeView not updating after a dataChanged signal

    Solved
    11
    0 Votes
    11 Posts
    2k Views
    SGaistS
    Quite the contrary, proper role handling is paramount to have a correctly working model view implementation.
  • QDialog border inherited by child QCheckBox

    Solved
    2
    0 Votes
    2 Posts
    186 Views
    JonBJ
    @Captain-Haddock self.setStyleSheet("MyDialog { background-color:#4C535D; ... }") I believe should prevent that inheritance?
  • reading from NetworkReply always give incomplete string of data

    Moved Unsolved
    7
    0 Votes
    7 Posts
    495 Views
    JonBJ
    @Ragbot Yes, assuming what you are getting is just JSON content, see void QNetworkReply::finished(). You can also do a readAll() there to read and save reply in one call. Presumably Ok unless package data is huge. Try just moving your readReady() to that signal?
  • Simple custom QVariant serialization not working

    Solved
    9
    0 Votes
    9 Posts
    981 Views
    P
    @Christian-Ehrlicher @Christian-Ehrlicher Thank you. Such an embarrasingly simple mistake.
  • Child widget gets event for parent widget ?...

    Unsolved
    11
    0 Votes
    11 Posts
    1k Views
    M
    @Oodini Seems you want to reinvent the wheel :) class LoggingDialog: public QDialog { Q_OBJECT public: LoggingDialog() : QDialog(nullptr) { setWindowTitle("Logging"); auto vLayout= new QVBoxLayout(this); vLayout->setSpacing(14); combo=new QComboBox; vLayout->addWidget(combo); auto label=new QLabel("Enter your password"); vLayout->addWidget(label,0,Qt::AlignCenter); edit=new QLineEdit; edit->setTextMargins(2,0,2,0); edit->setEchoMode(QLineEdit::Password); vLayout->addWidget(edit); auto button=new QPushButton("OK"); //button->setEnabled(false); vLayout->addWidget(button,0,Qt::AlignCenter); connect(button, &QPushButton::clicked, this,[this]() { bool ok=false; emit checkPassword(currentName(),edit->text(),ok); if(ok) { accept(); } else { // wrong password QMessageBox msgBox(this); msgBox.setWindowModality(Qt::WindowModal); msgBox.setText("Invalid password !"); msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel); if(msgBox.exec()==QMessageBox::Cancel) reject(); } }); } QString currentName() { return combo->currentText(); } signals: void checkPassword(const QString& name, const QString &pass,bool& ok); private: QComboBox* combo; QLineEdit* edit; }; ... LoggingDialog dialog; QObject::connect(&dialog,&LoggingDialog::checkPassword,[](const QString& name, const QString &pass,bool& ok) { ok=false; // msgbox will show up }); if(dialog.exec()==QDialog::Accepted) { qDebug()<<"Password correct for"<<dialog.currentName(); } else { qDebug()<<"operation cancelled"; } [image: Password.png]
  • Is it possible to use or reuse Windows file handle as QFile

    Solved
    8
    0 Votes
    8 Posts
    1k Views
    A
    Hey Simon, Yes, any simple scenario like CreateFile -> CloseHandle or QFile.open() -> QFile.close() works as expected, and the file is opened, then closed. When I mix them together I never see the close happening irrespective of QFileDevice flags provided and if CloseHandle() or QFile.close() is called. QFile.isOpened() returns false after the fact though.
  • QTextTospeech can't found engines

    Solved qtexttospeech linux qt5.15.2
    12
    0 Votes
    12 Posts
    2k Views
    .
    @jsulm I finally found my mistake, I'm missing the install qtspeech5-flite-plugin Thank you
  • QVulkanInstance: No such file or directory

    Moved Unsolved
    5
    0 Votes
    5 Posts
    504 Views
    S
    @Christian-Ehrlicher thank for notice solved
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    10 Views
    No one has replied
  • Moving a cell widget in a QTableWidget?

    Solved
    5
    0 Votes
    5 Posts
    1k Views
    Guy GizmoG
    @SGaist said in Moving a cell widget in a QTableWidget?: Well, the stated goal of setCellWidget is to show static content hence moving them around is not really part of the static content concept. That's too bad, and it seems like it's missing an obvious use case. I'm using cell widgets to display data in the table that is better served by a specific widget rather than just text in a cell. But since it's displaying data, it ought to be able to be moved around by dragging and dropping like every other cell, especially when it selects by row. In any case, I did find a solution! It's quite the hack and I really, really wish there was a better way to do it, but it works. After the user drops a row on to my table widget, I create a new column, populate it with integers that correspond to the new row indices after the drop, sort the table widget using that column, and then remove the column. I came upon this solution when I discovered that sorting the table widget would also move the cell widgets. It seems the trick is that it's calling changePersistentIndexList() behind the scenes, but even when subclassing there's no way for me to get access to the underlying model of the table and call that function to reorder things myself. It'd be great if: QTableWidget had built-in support for dragging and dropping rows when it's set to select by row Failing the above, there was a function for moving a cell widget to another cell so that you can implement the drag-and-drop behavior yourself.
  • How to read QWidget style margin?

    Unsolved
    5
    0 Votes
    5 Posts
    523 Views
    K
    @JonB said in How to read QWidget style margin?: try not to need to know such a detail. nice, and how ill find the data i need?
  • I don't understand QRandomGenerator.

    Unsolved
    4
    0 Votes
    4 Posts
    451 Views
    JonBJ
    @tsvigo Not sure quite what you mean or if there is still a question? QRandomGenerator has overloads which return quint32 or quint64 with generate[64]() and bounded(). If necessary pass your desired maximum value to bounded(). The return values of quint32 or quint64 are not "negative", they are unsigned/positive. What you do with that and when "written through the number" is a different matter.
  • multi nested dictionary

    Unsolved
    3
    0 Votes
    3 Posts
    372 Views
    SGaistS
    Hi, Beside the good question of @Pl45m4, it seems you would need a model on top of your nested dictionary and a QTreeView. Depending on what you do with your dictionary, using a QTreeWidget that you populate with your dict content might also be an option.