Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.9k Posts
  • Sending "bluez" error to GUI

    Unsolved
    7
    0 Votes
    7 Posts
    634 Views
    Christian EhrlicherC
    Don't see what this has to do with your connect() problem above but when you get an assertion you will use a debugger to see where it come from (as already told you many times)
  • Qt 3D arrow

    Unsolved
    1
    0 Votes
    1 Posts
    249 Views
    No one has replied
  • Question about QMultiHash:

    Solved
    7
    0 Votes
    7 Posts
    458 Views
    V
    Ahh... Sorry. I got it now. I was wrong. Thank you very much.
  • Add column to proxied Model

    Unsolved
    5
    0 Votes
    5 Posts
    1k Views
    AsevaPliuhaA
    It seems you're trying to append a 4th column to a QIdentityProxyModel that proxies a QFileSystemModel and is being used in a QTableView. You've tried incrementing the return value of column Count() and implementing index() as described in the linked thread, but are still running into issues. One thing to keep in mind is that when working with proxy models, it's important to ensure that the index mappings are properly set up and that the data is being correctly passed through the proxy. If the above methods did not help you, it's possible that there is an issue with the way the proxy model is being set up or configured. It would be best to check the documentation and make sure that the proxy model is properly configured. Another solution you can look into is using fast residential proxies to access your data in a different way, but it's not related to your current problem.
  • Continue editing if ItemModel::setData fails

    Unsolved
    16
    0 Votes
    16 Posts
    3k Views
    N
    @JonB said in Continue editing if ItemModel::setData fails: @numzero void QAbstractItemView::closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint) That's a virtual protected slot. Wonder what happens if you override that, check validity, and not call base? Does that keep it open, and are you still in an acceptable state?? <...> Just found https://stackoverflow.com/questions/54623332/qtableview-prevent-departure-from-cell-and-closure-of-delegate-editor That does work, mostly. Here is a sample: class MyView(QTreeView): _allow_close_editor = True def closeEditor(self, editor: QWidget, hint: QAbstractItemDelegate.EndEditHint): if not self._allow_close_editor: return super().closeEditor(editor, hint) self._allow_close_editor = True def commitData(self, editor: QWidget): self._allow_close_editor = False super().commitData(editor) def dataChanged(self, topLeft: QModelIndex, bottomRight: QModelIndex, roles: [int] = []): super().dataChanged(topLeft, bottomRight, roles) self._allow_close_editor = True However, it behaves poorly if the user tries to select another item while his input for the current one is not valid: the focus changes, but the editor remains open. editor.setFocus() doesn’t help. So here is a more advanced version, based on the SO answer: class MyItemDelegate(QStyledItemDelegate): def setModelData(self, editor: QWidget, model: QAbstractItemModel, index: QModelIndex) -> None: n = editor.metaObject().userProperty().name() if not n: n = d.editorFactory().valuePropertyName(model.data(index, Qt.EditRole).userType()) if n: commit_result = model.setData(index, editor.property(n), Qt.EditRole) if not commit_result: QMessageBox.warning(editor, 'Tree editor', 'Failed to update the value', QMessageBox.Ok) editor.setFocus() parent = editor while parent: if isinstance(parent, QAbstractItemView): parent.setCurrentIndex(index) break parent = parent.parent() editor.setProperty(MyView.COMMIT_RESULT_PROPERTY_NAME, commit_result) class MyView(QTreeView): COMMIT_RESULT_PROPERTY_NAME = '_myview_commit_result' def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setItemDelegate(MyItemDelegate(parent=self)) def closeEditor(self, editor: QWidget, hint: QAbstractItemDelegate.EndEditHint): commit_result = editor.property(self.COMMIT_RESULT_PROPERTY_NAME) editor.setProperty(self.COMMIT_RESULT_PROPERTY_NAME, None) if commit_result == False: return super().closeEditor(editor, hint) This almost works. Showing UI works, keeping editor state works. Still, has some weird behavior, like visual and actual focus not matching. Anyway, I suppose doing what I’m trying to do may not be exactly good idea anyway; it may be more confusing than helpful. And e.g. Dolphin does it differently: it lets the user continue editing in the dialog it shows, rather than in the view itself after showing the dialog. (Technically, it’s KIO what shows the dialog IIUC. And technically, Dolphin doesn’t use QTreeView either despite looking like one).
  • QAudioOutput vs QTimer strange behaviour

    Unsolved
    31
    0 Votes
    31 Posts
    4k Views
    jsulmJ
    @abarmotov Ah, right. Would be interesting to know why it was added - doesn't look correct to me and causes the issue you have.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    7 Views
    No one has replied
  • not enough arguments for function-like macro invocation 'realloc'

    Unsolved realloc include macro
    10
    0 Votes
    10 Posts
    3k Views
    SGaistS
    Hi and welcome to devnet, @KIMI2023 said in not enough arguments for function-like macro invocation 'realloc': I met the same question, (Debug version NG, release version OK) Solution: find file[crtdbg.h]:D:\Windows Kits\10\Include\10.0.19041.0\ucrt\crtdbg.h to commet follow: //#define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, FILE, LINE) Changing a file in the Windows development framework is not the correct way to handle that situation. As was done in the patch I linked, fixing the code is.
  • Can i rely to QStandardPaths

    Solved
    2
    0 Votes
    2 Posts
    210 Views
    Christian EhrlicherC
    @masa4 said in Can i rely to QStandardPaths: I am using it but can I be sure that always same location will be used in same computer? If you don't mpdify the system settings, yes How does it choose the path? By using system api calls to retrieve this information, on windows e.g. through ShGetFolderPath.
  • Can Qt build "paths" ?

    Unsolved qdir
    4
    0 Votes
    4 Posts
    1k Views
    Chris KawaC
    Internally Qt uses / as path separator, but all path taking APIs accept both / and \, so you can just always use / (which is easier because you don't have to escape it). If you need to pass the path to some native platform API or display it to the user in a platform correct form you can use QDir::toNativeSeparators, which will convert all the separators to current platform appropriate. It's usually not needed, but if you insist on building the platform correct path yourself you can use QDir::separator(). So both of those will do the same: QString path1 = QDir::toNativeSeparators("\\this/is\\my/fancy\\path"); QChar sep = QDir::separator(); QString path2 = sep + "this" + sep + "is" + sep + "my" + sep + "fancy" + sep + "path".
  • QGraphicsVideoItem not working with GStreamer media source

    Solved
    2
    0 Votes
    2 Posts
    507 Views
    X
    Nevermind, i fixed it, just had to update to Qt5.15 to get access to the video surface of the QGraphicsVideoItem and update the videosink to autovideosink. Here is my solution's code videoSubWindow::videoSubWindow(int shmID, int width, int height, QWidget* parent): QMdiSubWindow(), shmID(shmID), player(nullptr), videoWidget(nullptr) { std::cerr << __func__ << "\n"; std::string playerLaunch = "gst-pipeline: shmsrc socket-path=/tmp/shm" + std::to_string(shmID) + " ! video/x-raw, format=(string)I420, width=(int)" + std::to_string(width) + ", height=(int)" + std::to_string(height) + ", framerate=(fraction)30/1 ! queue ! videoconvert ! autovideosink"; scene = new QGraphicsScene(videoWidget); videoWidget = new roiVideoWidget(scene, this); videoItem = new QGraphicsVideoItem; scene->addItem(videoItem); player = new QMediaPlayer; player->setVideoOutput(videoItem->videoSurface()); player->setMedia(QUrl(playerLaunch.c_str())); player->play(); setWidget(videoWidget); setAttribute(Qt::WA_DeleteOnClose); }
  • Saving data before SubmitAll()

    Unsolved
    3
    0 Votes
    3 Posts
    293 Views
    I
    How are you adding that row to your QTableView ? void admin_interface::on_pushButton_add_clicked() { model->insertRow(model->rowCount()); } What is the rest of the logic when you click on that button? Before I tried to check the data in the tableView it looked like this void admin_interface::on_pushButton_refresh_clicked() { if(model->submitAll()) { } else if (model->lastError().text()==" No Fields to update") { qDebug()<<model->lastError().text(); QMessageBox::warning(this,"Error",""); } else { qDebug()<<model->lastError().text(); QString text = model->lastError().text(); QStringList lines = text.split( '\n' ); QMessageBox::warning(this,"Error",lines[0]); } model->setEditStrategy(QSqlTableModel::OnManualSubmit); row_count = model->rowCount(); }
  • Is there any way to get QPushButtons to render as fully opaque in macOS dark mode?

    Unsolved
    10
    0 Votes
    10 Posts
    838 Views
    SGaistS
    Then you should check the bug report system to see if there's already something about it there. If so, add informations on the ticket to help pinpoint the issue and if not, open a new one providing your minimal project there so it can be reproduced more easily.
  • 0 Votes
    7 Posts
    1k Views
    JoeCFDJ
    not sure how you handle your mqtt messages in qt code. Qt has a mqtt module and you may take a look at it. I guess you may not need a timer. Instead, you create a signal with info when the message comes and connect that signal with any other qt qwidgets for update. No check is needed as well.
  • TableView with multiple resize mode

    Unsolved
    2
    0 Votes
    2 Posts
    231 Views
    SGaistS
    Hi, One possible way would be to change the resize mode when the window state changes, get the result wanted and then change it back to interactive.
  • QSvgGenerator can embed specific fonts ?

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

    Unsolved
    1
    0 Votes
    1 Posts
    30 Views
    No one has replied
  • Problem with Connect and Lambda functions

    Solved
    12
    0 Votes
    12 Posts
    1k Views
    Chris KawaC
    @JonexElectronic Cool, no problem. The overload with just int is the one that is deprecated, so although more typing, it's better to use the other one. Fewer changes if you decide to update to Qt6 at some point. But either one is fine for now.
  • Using connect on a custom QSpinBox

    Solved
    7
    0 Votes
    7 Posts
    827 Views
    Dummie1138D
    @jsulm Thank you very much. I have previously neglected the detailed error messages for being messy, today is a good day to learn that they actually contain useful information.
  • error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]

    Unsolved
    3
    0 Votes
    3 Posts
    1k Views
    M
    @J-Hilk Thanks, I didnt want to replace them but in the end i did it. This one is most painless solution.