Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.7k Topics 457.9k Posts
  • Understanding QPalette

    Solved kde colors qpallete
    7
    0 Votes
    7 Posts
    4k Views
    Axel SpoerlA
    @tim-hilt Can you describe verbally which palette should be changed? The application palette? A specific widget’s palette? Something else? We’ll find it out!
  • How can i store data of database's different categories

    Unsolved
    7
    0 Votes
    7 Posts
    914 Views
    K
    Solved by creating QTableWidget. I transmited data from database in QTableWidget one query in a column and then row by row added data from QTableWidget to QString value to export it later to CSV.
  • Qt6, save TableView record in the database

    Unsolved qt6
    4
    0 Votes
    4 Posts
    383 Views
    Christian EhrlicherC
    @MyNick-0 said in Qt6, save TableView record in the database: How can I consider the data from the model You set data with setData() and retrieve it with data() as you should already know - if not please read the documentation about Qt's model/view framework can you bring the code? I don't write code for others when they don't provide code by themself in the first place so I see that they thought about the problem and tried things out by themself.
  • Problem loading MYSQL/MariaDB Driver in Manjaro Sikaris 22.0

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    supergS
    Well, I just found how to solve this. As stated in the output I posted above, the problem it's basically Qt being unable to find libqsqlmysql.so, but thanks to ChatGPT and google searches I found a workaround: Make sure that you have installed the MySQL client library on your system. You can check if it is installed by running the command locate libmysqlclient.so.21 (in case you are using Linux). Make sure that the MySQL driver library is in a location where your Qt application can find it. You can try adding the directory where the MySQL driver library is located to the LD_LIBRARY_PATH environment variable, by running the command: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mysql/lib Then, run Qt from terminal. For example, I do it with this command: ~/Qt/Tools/QtCreator/bin/qtcreator Thats it, now it should work. If you don't want to execute the export LD_LIBRARY_PATH=... command everytime before opening Qt, you can set LD_LIBRARY_PATH under environment (Where you add environment variables) . Example: [image: 0219fe83-192b-400b-acbe-db93587f7e35.png] After your default values in LD_LIBRARY_PATH, add ::/path/to/mysql/lib. If you do this, It's not necessary to open Qt from terminal anymore.
  • How to add new widgets between spacers in a QGridLayout?

    Unsolved
    3
    0 Votes
    3 Posts
    1k Views
    K
    @ChrisW67 said in How to add new widgets between spacers in a QGridLayout?: ou are asking the grid layout to add a new widget at the far right (index+1), and that is what it is doing. At index 0 is the left spacer, and at index 1 the right spacer, when I add the first button at index 1, it is added before or after the right spacer? The strange is that only one button gets to the middle. I also tried gridLayout->addWidget(btn, 2, index); and resulted on this: [image: 6d347ba3-c39a-4cfb-8eff-d3896bde3d42.png] I don't think adding a QHBoxLayout at the bottom is necessary for this task.
  • QGridLayout row positioning

    Solved
    2
    0 Votes
    2 Posts
    210 Views
    M
    Seems like done. Helped stretch property. PS grid.setRowStretch(0, 0) 0 row stretch 0 grid.setRowStretch(1, 6) 1 row stretch 6 [image: f3759d98-4128-412f-9333-e44fe5b8935f.png]
  • keyeventfilter place create object

    Solved
    5
    0 Votes
    5 Posts
    410 Views
    D
    @JoeCFD said in keyeventfilter place create object: this kind of definition MyKeyEventFilter myKeyEventFilter; can be fatal in your app sometimes. I would be really grateful if you could explain me why ?
  • Convert hexbyte to ASCII

    Unsolved
    3
    0 Votes
    3 Posts
    326 Views
    D
    @Christian-Ehrlicher thanks for response. I found simpler way to achieve my functionality: QString value = (QString::number(data, 16)).toUpper();
  • QMultimedia

    Unsolved
    2
    0 Votes
    2 Posts
    200 Views
    Christian EhrlicherC
    @Imman_Manny said in QMultimedia: QUrl::fromLocalFile("qrc:/sou/dropit.mp3") This is neither a local file nor a valid url.
  • Irregular progress chart

    Solved
    8
    0 Votes
    8 Posts
    502 Views
    Christian EhrlicherC
    @raziel said in Irregular progress chart: are these designed properties not yet fully set after setupUi? The layout manager adjusts the widgets during the showEvent() to make sure everything fits.
  • Qt6 Application OS Compatibility

    Unsolved
    10
    0 Votes
    10 Posts
    575 Views
    A
    Got it, thanks! I will try and update this post later.
  • QSqlDatabase - SQLite: How to load into :memory: and save :memory: to disk

    Unsolved
    18
    0 Votes
    18 Posts
    13k Views
    HoMaH
    I know this is a very old question, but I was struggeling with a similar question and found - with the current version of sqlite - a nice solution, which I wanted to share. My use case: save a database copy, with all personal data replaced by neutral strings. Solution: Create a new DB in memory Use SQL "VACUUM INTO .." to replicate the database into the inmemory database Use the same method, to save the database to the file system This code is from a minimal Qt Program with two buttons - one to create the source database (if it does not exist) the second button will create a modified copy on disc with the method described above. You can find the complete source code at github void MainWindow::on_pbGo_clicked() { QString imCon =ui->leConnectionName->text (); // "imCon" QString imDbName =ui->leDbName->text(); // "file::memory: { // open in memory database QSqlDatabase imDb =QSqlDatabase::addDatabase ("QSQLITE", imCon); imDb.setConnectOptions ("QSQLITE_OPEN_URI;QSQLITE_ENABLE_SHARED_CACHE"); imDb.setDatabaseName (imDbName); if( not imDb.open()) qCritical() << "failed to open inmemory DB " << imDb.lastError (); // open source db QSqlDatabase srcDb =QSqlDatabase::addDatabase ("QSQLITE", "source"); srcDb.setConnectOptions ("QSQLITE_OPEN_URI;QSQLITE_ENABLE_SHARED_CACHE"); srcDb.setDatabaseName ("source.db"); if( not srcDb.open ()) qCritical() << "failed to open source db " << srcDb.lastError (); // copy data to im db QSqlQuery qSourceToMemory (srcDb); if( not qSourceToMemory.exec(QString("VACUUM INTO '%1'").arg(imDbName))) qCritical() << "failed to copy data to inmemory db " << imDbName << "\n" << qSourceToMemory.lastError (); // change data QSqlQuery qModifyImDb(imDb); if( not qModifyImDb.exec ("INSERT INTO t (f) VALUES ('BrandNewData')")) qCritical() << "failed to modify in memory db " << qModifyImDb.lastError (); // save imdb to disc QSqlQuery qMemoryToDisc(imDb); QFile::remove("dest.db"); if( not qMemoryToDisc.exec(QString("VACUUM INTO '%1'").arg("dest.db"))) qCritical() << "failed to vacuum into dest db " << qMemoryToDisc.lastError (); // cleanup srcDb.close (); srcDb.close(); } QSqlDatabase::removeDatabase (imCon); QSqlDatabase::removeDatabase ("source"); } void MainWindow::on_pbexit_2_clicked() { { QSqlDatabase db =QSqlDatabase::addDatabase ("QSQLITE", "source"); db.setDatabaseName ("source.db"); if( not db.open ()) qCritical() << "failed to open source db for creation"; QSqlQuery q(db); if( not q.exec ("CREATE TABLE IF NOT EXISTS t (f TEXT PRIMARY KEY)")) qCritical() << "failed to create table" << q.lastError (); if( not q.exec ("REPLACE INTO t (f) VALUES ('Hallo'), ('World'), ('Welcome'), ('Aliens')")) qCritical() << "failed to write data"<< q.lastError (); db.close (); } // let QSqlQuery and QSqlDatabase run out of scope to close QSqlDatabase::removeDatabase ("source"); }
  • Template of QObject* conversation error C2234

    Solved
    12
    0 Votes
    12 Posts
    1k Views
    K
    If someone is interested in a generic list example for c++ and QML, enclosed the link.
  • Qt6 Support for MacOS Ventura/13.0

    Unsolved
    3
    0 Votes
    3 Posts
    587 Views
    S
    Quick check-in to update the record. After some searching and face-palming, I realized the SDKVersion issue was of my own doing in the build system. I'm able to use qmake to generate Makefiles again I'm running into the 'Can't find 'wchar.h' header' issue I've seen referenced elsewhere. I'm hoping to find a solution by following those threads. So... progress using Qt/opensource on MacOS Ventura, but still not working. I'll report back when I have more to tell.
  • Bundle FFmpeg with Qt6 application using CMake

    Solved qt6 c++17 ffmpeg cmake
    17
    0 Votes
    17 Posts
    6k Views
    A
    Ok, just to finalize this. Instead of the cmake code I attached above to link FFmpeg libraries, I used the same FindFFmpeg.cmake file that used by OBS Studio project on GitHub, and it worked as expected! I don't know what is the difference yet, I need to read through it carefully and find the differences.
  • QVarient outputting bogus data

    Unsolved
    11
    0 Votes
    11 Posts
    598 Views
    Christian EhrlicherC
    @SOrton said in QVarient outputting bogus data: int values[7] = {1,2,3,4}; //may not be these numbers but will be 4 single digit numbers. this is still wrong - there are only 4 numbers so it should be values[4]... And here the simple version of your code: values[4] = {1, 2, 3, 4} QString output; for (int val : values) output += QString::number(val) + ','; --> output = "1,2,3,4"
  • Custom MessageBox resizes when moving

    Solved
    4
    0 Votes
    4 Posts
    411 Views
    Chris KawaC
    @Dummie1138 said: All I want from this class is something that looks like a QMessageBox Then just use QMessageBox, e.g. QString title = "Friendly title"; QString text = "Password incorrect!"; QMessageBox box(QMessageBox::NoIcon, title, text, QMessageBox::Ok); box.findChild<QDialogButtonBox*>()->setCenterButtons(true); box.exec(); Btw. message box button placement in a QMessageBox conforms to platform guidelines. It's usually not a good idea to break them.
  • Qmenubar tittle issue

    Unsolved
    6
    0 Votes
    6 Posts
    408 Views
    Christian EhrlicherC
    Do you use some kind of css styling? A QMenu normally looks like this: https://doc.qt.io/qt-6/qmenu.html#details - yours looks strange.
  • How to know usb drive detected on qt ?

    Solved
    11
    0 Votes
    11 Posts
    3k Views
    Q
    @SGaist this script is doing auto mount of pendrive but unmount of pendrive not working. so i have decided to use mount and umount on triggering usb drive using ls -l /dev/sd* and then mount this device on media dir and then do umount on successful copy of file to pendrive
  • Passing a vector as function argument

    Solved
    4
    0 Votes
    4 Posts
    417 Views
    Kent-DorfmanK
    @SOrton said in Passing a vector as function argument: QVector<double> x(temp),y(temp); How can I place this into a functions paramater definition?: void MainWindow::plotGraph(int selectedIndex, QVector<double> x,y) Ok First thing. You need to create a "using" or "typedef" declaration for your container, as an alias when refering to the type later in your code using MY_VEC = QVector<double>; MY_VEC v1(27U); MY_VEC v2 = { 0.0, 1.0, 37.555 }; void someFunction(MY_VEC& v) { v.clear(); } someFunction(v2); Finally, don't put multiple variable declarations on the same line. It's considered bad form by most modern coding standards.