Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.3k Posts
  • SQLite record insertion isn't correct using eventFilter() to catch the Enter key

    Solved
    5
    0 Votes
    5 Posts
    181 Views
    Y
    @Christian-Ehrlicher Debugger was not even necessary because the problem was just student's inexperience: i just needed to find QSqlQuery::at() in documentation and replace this piece of stupidity: QString DataProcessor::getValue(QString tableName, int recordNum, int colNum) { QSqlQuery query = selectAll(tableName); QStringList colTypes = getColTypes(tableName); QString value = ""; int i = 0; while( i <= 0) { if (query.next() == recordNum) { value = query.value(colNum).toString(); i++; } } return value; } by this: QString DataProcessor::getValue(QString tableName, int recordNum, int colNum) { QSqlQuery query = selectAll(tableName); QStringList colTypes = getColTypes(tableName); QString value = ""; while(query.next()) { if (query.at() == recordNum) { value = query.value(colNum).toString(); } } return value; }
  • read QString type Q_PROPERTY in axserver from js always return empty

    Solved
    2
    0 Votes
    2 Posts
    196 Views
    Y
    I finally solved this. It's actually kind stupid: name cannnot be used as Q_PROPERTY name. After I change the property name, it works.
  • Passing control+keypress instructions from one form to another

    Unsolved
    4
    0 Votes
    4 Posts
    353 Views
    Pablo J. RoginaP
    @donquibeats said in Passing control+keypress instructions from one form to another: works immediately. great, so don't forget to mark your post as solved then!
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    7 Views
    No one has replied
  • Sorting a QAbstractItemModelReplica via QSortFilterProxyModel doesn't update the view

    Unsolved
    1
    0 Votes
    1 Posts
    132 Views
    No one has replied
  • Cast QVariant to int

    Solved
    5
    0 Votes
    5 Posts
    3k Views
    JonBJ
    @TomNow99 But there isn't, for the same reason. QDataStream operator << needs to know the type at compile time, just the same question as before. Because we are C++ and that is a strongly typed language. Unless you're willing to stream it as a QVariant, which is not what you want. At the end of the day you can write a method just like you've shown just with the necessary ifs/switch for all the QVariant types you want to handle, which might be a dozen? Once you've written the method once, it's done.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    11 Views
    No one has replied
  • 0 Votes
    4 Posts
    3k Views
    B
    @learnist said in How to edit a QListwidgetItem by using custom context menu ? need some corrections: but for point 3 ,which edit trigger should i use ?? can you please elaborate If you don't want double clicking or any key pressing to trigger the editing, just set it to QAbstractItemView::NoEditTriggers.
  • MacOs sandbox, security scoped bookmarks

    Unsolved macosx sandbox bookmarks
    4
    0 Votes
    4 Posts
    1k Views
    B
    @YuChao-Hsu That's Objective C++. The code need to be in a *.mm file.
  • creating proxy gui which i can operate remotely using QRemoteObject

    Unsolved
    1
    0 Votes
    1 Posts
    121 Views
    No one has replied
  • 0 Votes
    5 Posts
    2k Views
    johnratiusJ
    @Bonnie I see. I got it to work now. Thanks.
  • How to force QDialogue to be on top/not on top of MainWindow

    Unsolved
    7
    0 Votes
    7 Posts
    806 Views
    L
    Yes, I just figured that out. So this works for those interested. //Slot to force a plot widget to always be on top or not - alwaysOnTopFlag = true means always on top void MainWindow::getAlwaysOnTopFlag(int widgetID, bool alwaysOnTopFlag) { if(alwaysOnTopFlag == true) { dialogue->setWindowFlags(windowFlags() | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); dialogue->setParent(NULL); //allow the plotWidget not to go behind the main window dialogue->setWindowFlags(windowFlags() & ~Qt::CustomizeWindowHint); dialogue->setWindowFlags(windowFlags() | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); dialogue->setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); //add a minimize button dialogue->setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); //always on top dialogue->show(); } else { dialogue->setWindowFlags(windowFlags() & ~Qt::CustomizeWindowHint); dialogue->setWindowFlags(windowFlags() | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); dialogue->setParent(NULL); //allow the plotWidget to go behind the main window dialogue->setWindowFlags(windowFlags() | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint); //add a minimize button dialogue->setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); //not on top dialogue->show(); } } Would a pin be easier or better? If so is there an easy way to implement?
  • Change a label's text when a variable changes

    Solved
    3
    0 Votes
    3 Posts
    1k Views
    R
    @JonB Thank you that worked great
  • QProcess output lines are truncated to 80 columns

    Unsolved
    3
    0 Votes
    3 Posts
    415 Views
    A
    @MuratUrsavas said in QProcess output lines are truncated to 80 columns: If I debug the process (a standard Linux command) and try to get the output with readAllOutputStandard(), I see that each line has been truncated to 80 characters. ??? That should be sufficient description of the issue. My current usage "shows " almost 200 characters. In my search I found QProcess has inherited form QIODevice and this note qint64 QIODevice::peek(char * data, qint64 maxSize) Reads at most maxSize bytes from the device into data, without side effects (i.e., if you call read() after peek(), you will get the same data). Returns the number of bytes read. If an error occurs, such as when attempting to peek a device opened in WriteOnly mode, this function returns -1. Perhaps further search for "maxSize" could answer the question.
  • QByteArray toLong false

    Unsolved
    14
    0 Votes
    14 Posts
    1k Views
    Pl45m4P
    @JonB As I've said, I dont know what OP is trying to do with his long later ( sounds wrong... :-D ). If it's somehow important for the value to be higher than 0, this would definitely crash then... Just my thoughts. And I didnt mentioned any pointer :)
  • What is "inferior" ?

    Solved
    7
    -1 Votes
    7 Posts
    729 Views
    Pl45m4P
    @AnneRanch If you would have deleted this stuff here, @KH-219Design wouldn't be able reply to your post. You've deleted your original post only and not the whole thread (which will indeed remove everything, so that nobody, except admins and moderators - I guess, can read it anymore). You can delete / remove everything by using the topic-tools... The menu with the three vertical dots below your first post will just delete your very first question.
  • shift-F11 stopps debugging

    Unsolved
    10
    0 Votes
    10 Posts
    743 Views
    HoMaH
    Sorry for the late reply. I did a reinstall and with this a switch to msvc. Now it works. I was on mingw before. Best regards Holger
  • QRegExp to parse a CSV file

    Solved
    10
    0 Votes
    10 Posts
    788 Views
    Pablo J. RoginaP
    @Merlino said in QRegExp to parse a CSV file: simple CSV file If the file conforms to such format, you should have one and only one marker as field separator. Originally a comma (so the name) but later on some other character (that obviously cannot be part of the field values...) @Gojir4 Can't you simply use line.split(";") ? Yes you can. @Gojir4 provided the right answer I guess. From you data example, in your case it seems to be a SCSV file indeed: a semi-colon separated values. @Merlino about 2 hours ago no because the string fields can contain punctuation and quotation marks so the simple split would be fooled. Yes, you'll have punctation and quotation marks in the string fields, but I bet none of such characters will be a semi-colon (;) It looks like you're over-complicating your use case.
  • Opening txt files in qt c++ and writing to it.

    Unsolved
    5
    0 Votes
    5 Posts
    2k Views
    JonBJ
    @Alfie-Anil said in Opening txt files in qt c++ and writing to it.: QFile file("urlfile.txt"); This file will be relative to whatever the current directory happens to be in your application at the time the line is executed. Which may or may not be correct. Safer would be to use an absolute path. the same location as the directory that the project is saved in I don't know what "the directory that the project is saved in" is. There will not be any Qt methods to retrieve such a thing. There will be for, say, where the executable is being run from. Writing to such a location at runtime is not a good idea anyway. Look through https://doc.qt.io/qt-5/qstandardpaths.html#StandardLocation-enum to find a suitable one for where you want to save the file, and use that to build the absolute path.
  • How to resize QTableWidget width to fit the total column size?

    Solved
    2
    0 Votes
    2 Posts
    2k Views
    L
    Ok this worked: self.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Expanding)