Hiring Qt Developer for Spatial Audio solution - London UK
Hello,
As the title states, my company Focusrite Group are currently looking for a Qt developer, working in C++. We are developing some exciting new software/hardware solutions in the live spatial audio field. The job will be based out of Tileyard, London UK, which is in the Kings Cross area of London.
If you are interested, please check out the following link for the application form/more details. We are a small team, working on some exciting projects with the backing of a major PLC, so this is an exciting time to join the project.
Any questions, drop me a DM or comment.
Cheers,
Dan Higgott
TiMax Spatial
https://redd.it/1fv3kmk
@qt_reddit
Open Source alternatives to QT
Our management is stepping away from QT due to the dramatic increase in licensing fees.
Is there a generally accepted preference among the many alternatives to the QT framework? Ideally an open source option.
Is there an alternative that allows for the import/conversion of QML files? We have an enormous library of custom QML, and while I realize any kind of import would certainly require lots of bugfixing, we don't want to have to rewrite from scratch.
https://redd.it/1fukdza
@qt_reddit
Selecting a dir to install my app on linux
Hello.
I've developed a Qt app for Linux which should be enforced to run on non admin users of the machine (it enforces watermark on top of all screens)
they should not have a way to close or edit any of its files (or it will lose its purpose.
I wanted to make it get installed into a dir which all users can see. Therefore, I made my installer to put the app inside /usr/local/share/<myapp> so that only admin accounts can execute it ( the app also reads/writes to this directory thus needs sudo also) but it is available for all.
The app also installs a systemd service which executes the app on startup.
My problem is:
1- Is the way I did the ideal way to achieve my goal (app run as sudo for regular users to prevent them from touching its files or closing it)
2- systemd services seems working well when the target app to run does not have a display (just console app), however, when it executes the qt app (GUI one) execution fails and it seems due to no display when running from systemd
I would like to hear from experienced devs here. Thanks in advance
https://redd.it/1fu1qo0
@qt_reddit
ui-> false condition
Hey everyone hope all is well,
Quick question, in my GUI I have 4 lineEdit's that disappear after a button is pressed (1 per button). Now after all 4 are pressed I want to create an if function that switches numbers by lowest to greatest. But my if function gets errors, is there a simple way around this?
https://preview.redd.it/hvpxx9gxx0sd1.png?width=1625&format=png&auto=webp&s=bc758663dfe19d2373f8115d6695beb945af78ef
https://redd.it/1ft8sj4
@qt_reddit
Why Qt Creator indentation is so f...d?
It's a rethorical question, actually.
But if you know what is a good fix for the problem, you're welcome, currently I tried the default indentation, and Beatifier plugin, that didn't work for me. Sometimes the indentation is absolutely random, even though I don't miss ';' ')' or '}'
https://redd.it/1ft3hov
@qt_reddit
`X11 specific:`
`XLib ................................. no`
`XCB Xlib ............................. no`
`EGL on X11 ........................... no`
`xkbcommon-x11 ........................ no`
`QPA backends:`
`DirectFB ............................... no`
`EGLFS .................................. no`
`LinuxFB ................................ no`
`VNC .................................... no`
`Windows:`
`Direct 2D ............................ yes`
`DirectWrite .......................... yes`
`DirectWrite 2 ........................ yes`
`Qt Sql:`
`SQL item models ........................ no`
`Qt Widgets:`
`GTK+ ................................... no`
`Styles ................................. Fusion Windows WindowsVista`
`Qt PrintSupport:`
`CUPS ................................... no`
`Qt Sql Drivers:`
`DB2 (IBM) .............................. no`
`InterBase .............................. no`
`MySql .................................. no`
`OCI (Oracle) ........................... no`
`ODBC ................................... no`
`PostgreSQL ............................. no`
`SQLite2 ................................ no`
`SQLite ................................. no`
`Using system provided SQLite ......... no`
`TDS (Sybase) ........................... no`
`Qt Testlib:`
`Tester for item models ................. yes`
`Qt Tools:`
`Qt Assistant ........................... yes`
`Qt Designer ............................ yes`
`Qt Distance Field Generator ............ yes`
`kmap2qmap .............................. yes`
`Qt Linguist ............................ yes`
`Mac Deployment Tool .................... no`
`makeqpf ................................ yes`
`pixeltool .............................. yes`
`qdbus .................................. yes`
`qev .................................... yes`
`Qt Attributions Scanner ................ yes`
`qtdiag ................................. yes`
`qtpaths ................................ yes`
`qtplugininfo ........................... yes`
`Windows deployment tool ................ yes`
`WinRT Runner Tool ...................... no`
`Qt Tools:`
`QDoc ................................... no`
`Note: Using static linking will disable the use of dynamically`
`loaded plugins. Make sure to import all needed static plugins,`
`or compile needed modules into the library.`
`WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.`
`Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation.`
`On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution.`
`On macOS, you can use Homebrew's llvm package.`
`On Windows, you must set LLVM_INSTALL_DIR to the installation path.`
`ERROR: Feature 'openssl-linked' was enabled, but the pre-condition '!features.securetransport && !features.schannel && libs.openssl' failed.`
`Check config.log for details.`
https://redd.it/1fsn03w
@qt_reddit
Qt Static Build with OpenSSL
Hello, I'm building Qt statically, with Openssl to use SSL classes.
I've installed openssl using Chocolatey and the path in EVs is set to `C:\Program Files\OpenSSL-Win64\bin` but I'm still providing the path OPENSSL\_ROOT\_DIR and getting this:
`D:\Downloads\qt-everywhere-src-5.15.5\build>..\configure -release -silent -opensource -confirm-license -opengl desktop -static -static-runtime -mp -qt-zlib -qt-pcre -qt-libpng -nomake examples -nomake tests -nomake tools -no-angle -no-dbus -no-gif -no-gtk -no-ico -no-icu -no-libjpeg -no-libudev -no-sql-sqlite -no-sql-odbc -no-sqlite -no-vulkan -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip doc -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtlottie -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquick3d -skip qtquickcontrols -skip qtquickcontrols2 -skip qtquicktimeline -skip qtremoteobjects -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebglplugin -skip qtwebsockets -skip qtwebview -skip qtx11extras -skip qtxmlpatterns -no-feature-printdialog -no-feature-printer -no-feature-printpreviewdialog -no-feature-printpreviewwidget -no-feature-sql -no-feature-sqlmodel -no-feature-textbrowser -no-feature-textmarkdownwriter -no-feature-textodfwriter -no-feature-xml -prefix C:\Qt_static -openssl-linked -DOPENSSL_ROOT_DIR="C:\Program Files\OpenSSL-Win64"`
`+ cd qtbase`
`+ D:\Downloads\qt-everywhere-src-5.15.5\qtbase\configure.bat -top-level -release -silent -opensource -confirm-license -opengl desktop -static -static-runtime -mp -qt-zlib -qt-pcre -qt-libpng -nomake examples -nomake tests -nomake tools -no-angle -no-dbus -no-gif -no-gtk -no-ico -no-icu -no-libjpeg -no-libudev -no-sql-sqlite -no-sql-odbc -no-sqlite -no-vulkan -skip qt3d -skip qtactiveqt -skip qtandroidextras -skip qtcharts -skip qtconnectivity -skip qtdatavis3d -skip qtdeclarative -skip doc -skip qtdoc -skip qtgamepad -skip qtgraphicaleffects -skip qtimageformats -skip qtlocation -skip qtlottie -skip qtmacextras -skip qtmultimedia -skip qtnetworkauth -skip qtpurchasing -skip qtquick3d -skip qtquickcontrols -skip qtquickcontrols2 -skip qtquicktimeline -skip qtremoteobjects -skip qtscript -skip qtscxml -skip qtsensors -skip qtserialbus -skip qtserialport -skip qtspeech -skip qtsvg -skip qtvirtualkeyboard -skip qtwayland -skip qtwebchannel -skip qtwebengine -skip qtwebglplugin -skip qtwebsockets -skip qtwebview -skip qtx11extras -skip qtxmlpatterns -no-feature-printdialog -no-feature-printer -no-feature-printpreviewdialog -no-feature-printpreviewwidget -no-feature-sql -no-feature-sqlmodel -no-feature-textbrowser -no-feature-textmarkdownwriter -no-feature-textodfwriter -no-feature-xml -prefix C:\Qt_static -openssl-linked -DOPENSSL_ROOT_DIR="C:\Program Files\OpenSSL-Win64"`
`Bootstrapping qmake ...`
`jom 1.1.4 - empower your cores`
`This is the Qt Open Source Edition.`
`You have already accepted the terms of the Open Source license.`
`Running configuration tests...`
`Done running configuration tests.`
`Configure summary:`
`Build type: win32-msvc (x86_64, CPU features: sse sse2)`
`Compiler: msvc 194134120`
`Configuration: sse2 aesni sse3 ssse3 sse4_1 sse4_2 avx avx2 avx512f avx512bw avx512cd avx512dq avx512er avx512ifma avx512pf avx512vbmi avx512vl compile_examples f16c largefile msvc_mp precompile_header rdrnd rdseed shani silent x86SimdAlways release c++11 c++14 c++17 c++1z concurrent no-pkg-config static static_runtime stl`
`Build options:`
`Mode ................................... release`
`Optimize release build for size ........ no`
`Building shared libraries .............. no`
`Using C standard ....................... C89`
`Using C++ standard ..................... C++17`
`Relocatable ............................ no`
`Using precompiled headers
Qt build and linking errors
Guys please help with these errors, my post are getting deleted here
https://www.reddit.com/r/Bitcoin/s/loGQUmPMJe
https://redd.it/1frziya
@qt_reddit
Quick3d outline shader?
It seems like a basic feature of a 3d engine, however I'm having trouble finding a method that works.
Can anyone point me in the right direction?
https://redd.it/1fqct5t
@qt_reddit
Hello everyone, does anyone know of a lightweight, cross-platform, open-source library that supports capturing screenshots of the desktop?
I want to monitor multiple controlled endpoints in remote desktop software. Since real-time performance isn't critical, I don't want to implement this using audio or video streaming.
My current idea is to have the controlled endpoints periodically capture screenshots and send them to the controlling endpoint for display. The library I'm looking for needs to be cross-platform, lightweight, and able to support multiple screens on a single device.
1. set a timer to grab screen, and push to server , for another monitor,
2. suppot macOS , linux and windows
3. support multi screen
Any recommendations or advice would be greatly appreciated!
https://redd.it/1fotlrv
@qt_reddit
Need help with licensing
I am making my own open source program using QT creator for the GUI. I want to distribute it on github. I am not making any modifications to any QT components.
Can I just go ahead and use a GPL license for the project? Or are there special licenses?
Any help will be much appreciated.
https://redd.it/1fn104e
@qt_reddit
Is it safe to commit entire Qt projects to Github?
So I have a Qt project, and using Github Desktop I created a repository for the root folder. Whenever I do a commit, it also commits all these build files and other things like CMakeLists.txt.user which aren't files I edited. I understand that these are for building on my machine, so I'm concerned that maybe there's maybe stuff on them I shouldn't make public in a Github repo. What does everyone think?
https://redd.it/1fmiky9
@qt_reddit
Qt checkbox not behaving as expected, how to fix?
https://redd.it/1fknucu
@qt_reddit
QTextStream in(&file);
//Store score to string and make it 4 digits
QString line = ui->Player2Sel_B->currentText();
score = ui->lineEdit_2->text();
score.truncate(4);
//Search for string in UI, delete after
QString search(line);
QList<QListWidgetItem *> list = ui->listWidget_2->findItems(line, Qt::MatchContains);
for ( QListWidgetItem *item : list )
delete item;
//Temp store line string to another and delete data after ":"
name = line;
int pos = name.lastIndexOf(QChar(':'));
line = name.left(pos);
//New string and add name string with score and update UI
QStringList stringList;
stringList << line+':'+'\t'+'\t'+'\t'+score;
ui->listWidget_2->addItems(stringList);
//Update the text file from UI
auto numRows = ui->listWidget_2->count();
for(int row = 0; row < numRows; ++row)
{
auto item = ui->listWidget_2->item(row);
QString s;
s = item->text();
file.resize(0); // Deletes all data from the textfile
in<<s; //adds row to text file
in<<"\n"; //adds a line break
}
file.close();
}
https://redd.it/1fig2ds
@qt_reddit
What is something we could expect with Qt 7?
Right now, all my software is running on Qt 5.15. There are currently no major feature in Qt 6 that would want me to spend the time to port from Qt 5.X to 6.X. But I was wondering, if the Qt Company were to start developing Qt 7.X, what would it look like? What feature do you think would be added and what would be removed?
https://redd.it/1funakp
@qt_reddit
ChatGPT
I just asked ChatGPT to write me a C++ time axis widget. It did a pretty good job and then suggested enhancements for pan/zoom, inertia pan, keyboard and mouse wheel support, major/minor tick marks. I was expecting a mash up of Qt Forum and Stack Exchange snippets, but it seems to have generated new and unique code. The final iteration of code had a few compile errors that look easy to resolve (due to some doubled up function definitions holding over the prior versions in the new output), but the prior four iterations were sound. I had assumed the current generation of AI was just search on steroids, but it seems so much more. This is a huge productivity boost.
https://redd.it/1fu32p6
@qt_reddit
Is there a way i can have something like in my own app?
https://preview.redd.it/zpaukqjji3sd1.png?width=480&format=png&auto=webp&s=1c2519362c41f9b5cdf16d899bfcb3d86c72adab
I made a simple text editor using PySide6, but i want something like this when the user clicks Power Off and there is unsaved work
https://redd.it/1fti9lv
@qt_reddit
Declaring window manager hints 🪟
On QML, is there a way to declare window manager hints?
Like:
- _NET_WM_STATE_SKIP_TASKBAR
- _NET_WM_BYPASS_COMPOSITOR
I see you can declare flags like:
import QtQuick
Window {
visible: true
flags: Qt.[FLAG]
}
qml6 "${PWD}/[SCRIPT].qml"
Qt Creator Toolbar - plugin
Hi all,
anyone know is there's a plugin that simply adds a toolbar for Qt Creator ? I've looked for it, but couldn't find it
Cheers
https://redd.it/1fsq54t
@qt_reddit
.............. yes`
`Using LTCG ............................. no`
`Target compiler supports:`
`SSE .................................. SSE2 SSE3 SSSE3 SSE4.1 SSE4.2`
`AVX .................................. AVX AVX2`
`AVX512 ............................... F ER CD PF DQ BW VL IFMA VBMI`
`Other x86 ............................ AES F16C RDRAND SHA`
`Build parts ............................ libs`
`App store compliance ................... no`
`Qt modules and options:`
`Qt Concurrent .......................... yes`
`Qt D-Bus ............................... no`
`Qt D-Bus directly linked to libdbus .... no`
`Qt Gui ................................. yes`
`Qt Network ............................. yes`
`Qt Sql ................................. no`
`Qt Testlib ............................. yes`
`Qt Widgets ............................. yes`
`Qt Xml ................................. no`
`Support enabled for:`
`Using pkg-config ....................... no`
`udev ................................... no`
`Using system zlib ...................... no`
`Zstandard support ...................... no`
`Qt Core:`
`DoubleConversion ....................... yes`
`Using system DoubleConversion ........ no`
`GLib ................................... no`
`iconv .................................. no`
`ICU .................................... no`
`Built-in copy of the MIME database ..... yes`
`Tracing backend ........................ <none>`
`Logging backends:`
`journald ............................. no`
`syslog ............................... no`
`slog2 ................................ no`
`PCRE2 .................................. yes`
`Using system PCRE2 ................... no`
`Qt Network:`
`getifaddrs() ........................... no`
`IPv6 ifname ............................ no`
`libproxy ............................... no`
`Schannel ............................... no`
`OpenSSL ................................ no`
`Qt directly linked to OpenSSL ........ no`
`OpenSSL 1.1 ............................ no`
`DTLS ................................... no`
`OCSP-stapling .......................... no`
`SCTP ................................... no`
`Use system proxies ..................... yes`
`GSSAPI ................................. no`
`Qt Gui:`
`Accessibility .......................... yes`
`FreeType ............................... yes`
`Using system FreeType ................ no`
`HarfBuzz ............................... yes`
`Using system HarfBuzz ................ no`
`Fontconfig ............................. no`
`Image formats:`
`GIF .................................. no`
`ICO .................................. no`
`JPEG ................................. no`
`Using system libjpeg ............... no`
`PNG .................................. yes`
`Using system libpng ................ no`
`Text formats:`
`HtmlParser ........................... yes`
`CssParser ............................ yes`
`OdfWriter ............................ no`
`MarkdownReader ....................... yes`
`Using system libmd4c ............... no`
`MarkdownWriter ....................... no`
`EGL .................................... no`
`OpenVG ................................. no`
`OpenGL:`
`ANGLE ................................ no`
`Desktop OpenGL ....................... yes`
`Dynamic OpenGL ....................... no`
`OpenGL ES 2.0 ........................ no`
`OpenGL ES 3.0 ........................ no`
`OpenGL ES 3.1 ........................ no`
`OpenGL ES 3.2 ........................ no`
`Vulkan ................................. no`
`Session Management ..................... yes`
`Features used by QPA backends:`
`evdev .................................. no`
`libinput ............................... no`
`INTEGRITY HID .......................... no`
`mtdev .................................. no`
`tslib .................................. no`
`xkbcommon .............................. no`
How to develop GUI apps using the KDE Kirigami set of Qt Quick QML controls
https://www.youtube.com/watch?v=Jf4gJq3nGhA
https://redd.it/1fs67wy
@qt_reddit
Qt requires a C++ 17 compiler, not resolved within CMake and Visual Studio
I am trying to create a very basic Qt hello world using CMake. The paths have been configured correctly but when I attempt to compile it in Visual Studio I receive the error,Qt requires a C++ 17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler
However, following the other suggestions my CMakeLists.txt is configured correctly to set it
cmakeminimumrequired(VERSION 3.16)
project(HelloQt6 VERSION 1.0.0 LANGUAGES CXX)
list(APPEND CMAKEPREFIXPATH C:/Qt/6.7.2/mingw64)
set(CMAKECXXSTANDARD 17) <- This is set
set(CMAKECXXSTANDARDREQUIRED ON)
findpackage(Qt6 REQUIRED COMPONENTS Widgets)
qtstandardprojectsetup()
qtaddexecutable(HelloQt6 src/main.cpp)
targetlinklibraries(HelloQt6 PRIVATE Qt6::Widgets)
In Visual Studio I can see that the C++ Language Standard is also set,
https://preview.redd.it/a44ivnrjkard1.png?width=1181&format=png&auto=webp&s=a55f726dc4153d998b523387c1e892c454633a6c
I do not know what is left to test. Could anyone please help me resolve this issue?
https://redd.it/1fqgzxy
@qt_reddit
I made a rather attractive Qt Widgets app
https://preview.redd.it/zo78o7udqyqd1.jpg?width=1500&format=pjpg&auto=webp&s=b6fbe0edb7fea6662578ff404a335329787aed89
[https://github.com/flowkeeper-org/fk-desktop/](https://github.com/flowkeeper-org/fk-desktop/) or [https://flowkeeper.org](https://flowkeeper.org)
PySide6, latest Qt 6, Qt Widgets, GPLv3 license.
This hobby app took me about a year to reach its current state. The GitHub pipeline builds a Windows installer, a DEB, a DMG, and some portable binaries. The app supports recent macOS, Windows 10 and 11, and any mainstream Linux released within a couple of years, e.g. Ubuntu 22.04.
Feel free to reuse parts of it, or ask me any questions about how things are implemented. It has examples of Qt
* Resources,
* Theming,
* QSS,
* WebSockets,
* OAuth,
* Audio,
* Actions with configurable shortcuts,
* TableViews with custom delegates,
* Custom visualization / painting,
* Search with auto-completion,
* Wizards,
* Charts,
* Window state trickery -- saving size on exit, minimize to tray, move via dragging window content, ...,
* Checking GitHub Releases for updates,
* Home-made tutorial with call-outs,
* Home-made generic Settings dialog,
* Home-made end-to-end tests.
Of course, I would appreciate if you have any feedback about the code or the app itself. Thanks!
https://redd.it/1fp5t17
@qt_reddit
qtedit4 - a new text editor
Hi all,
I am releasing the first release of my text editor. Its fully done in Qt6, cross platform (Linux app image and Windows installer is available, contributions for OSX packages are welcomed). My goal is to make a good text editor as a foundation, and then grow this into a full IDE.
https://github.com/diegoiast/qtedit4/
https://github.com/diegoiast/qtedit4/releases/tag/v0.0.1
https://redd.it/1fogu51
@qt_reddit
I dont know how to import a project and make it work
Hi, as the title says i cant import a project and make it work. So, im new to Qt and i have a couple of files that my professor has given us and i dont know how to import it and compile. I have .cc, .h files and a .pro file that i think is for compiling, but i dont know how to configure it and im very confused.
Image of the folder.
Thanks in advance.
https://preview.redd.it/xhg50jqv37qd1.png?width=1400&format=png&auto=webp&s=2384d3adfc7519aac7a5746a0eba3a18239bd47d
https://preview.redd.it/pycr2jay37qd1.png?width=694&format=png&auto=webp&s=9669588c13ca5f3ebf110fe1bae10bf99734f1e1
https://redd.it/1fm7wos
@qt_reddit
Qt AudioPlayer No Audio Output
#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QStyle>
#include <QPixmap>
#include <QPalette>
#include <QFileDialog>
#include <QFileInfo>
#include <QUrl>
#include <QAudioOutput>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
M_Player = std::make_unique<QMediaPlayer>(this);
M_A_Player = std::make_unique<QAudioOutput>(this);
ui->play_audio->setIcon(style()->standardIcon(QStyle::SP_MediaPlay));
ui->pause_audio->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
// Setting background image
QPixmap background("/home/Desktop/MulMed/res/black_screen.jpeg");
background = background.scaled(this->size(), Qt::IgnoreAspectRatio);
QPalette palette;
palette.setBrush(QPalette::Window, background);
this->setPalette(palette);
// Set slider range (if not already set)
ui->audio_volume->setRange(0, 100);
// Connect slider valueChanged to adjust volume
connect(ui->audio_volume, &QSlider::valueChanged, this, &MainWindow::on_audio_volume_valueChanged);
}
MainWindow::\~MainWindow()
{
delete ui;
}
void MainWindow::on_actionOpen_Audio_File_triggered()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Select audio file"), "", tr("MP3 Files (*.mp3);;All Files (*)"));
M_Player->setSource(QUrl::fromLocalFile(fileName));
QFileInfo File(fileName);
ui->audio_value->setText(File.fileName());
// Set the initial volume based on the slider value
M_A_Player->setVolume(ui->audio_volume->value() / 100.0); // Convert to range [0.0, 1.0\]
}
void MainWindow::on_play_audio_clicked()
{
M_Player->play();
}
void MainWindow::on_pause_audio_clicked()
{
M_Player->pause();
}
void MainWindow::on_audio_volume_valueChanged(int value)
{
qDebug() << "Slider Value Changed:" << value;
qDebug() << "Setting Volume to:" << value / 100.0;
M_A_Player->setVolume(value / 100.0); // Convert to range [0.0, 1.0\]
}
, i'm using vertical slider for volume change, I can't play music with this but the audio file uploads fine can anyone help me with this?
https://redd.it/1fkrv3p
@qt_reddit
GitHub - Palm1r/QodeAssist: QodeAssist is an AI-powered coding assistant plugin for Qt Creator
https://github.com/Palm1r/QodeAssist
https://redd.it/1fjt1sn
@qt_reddit
Qt wont save data on same text file
Good afternoon hope everyone's good
So in my senior project I have 4 text files that store a players name and score, problem is that say player 1 and player 2 are in the same text file my Qt wont store player 1 new score just player 2. I have them in separate buttons on clicked and in theory I should have an issue. Ive tried changing variable names and I still have issues. So then I designed a new Qt project but only focused on this issue, I have the google drive link incase anyone wants to down load it and try it and I will also attach the code and picture.
[https://drive.google.com/file/d/1bvCrflESUrpxeGqtA9Cm5W2Y61sTYw9W/view?usp=drive\_link](https://drive.google.com/file/d/1bvCrflESUrpxeGqtA9Cm5W2Y61sTYw9W/view?usp=drive_link)
https://preview.redd.it/xs421ni1l8pd1.png?width=1263&format=png&auto=webp&s=70fc130b3321fcce3fe7ecd76d404ae1318ffa52
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QFile"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_sel1_2_clicked()
{
QFile file1stcs("Test.txt");
file1stcs.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream incs(&file1stcs);
while(!incs.atEnd())
{
QString line = incs.readLine();
ui->Player1Sel_A->addItem(line);
ui->listWidget->addItem(line);
}
file1stcs.close();
}
void MainWindow::on_sel2_clicked()
{
QFile file1stcs("Test.txt");
file1stcs.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream incs(&file1stcs);
while(!incs.atEnd())
{
QString line = incs.readLine();
ui->Player2Sel_B->addItem(line);
ui->listWidget_2->addItem(line);
}
file1stcs.close();
}
//***********************SAVE Buttons************************************************************
void MainWindow::on_pushButton_5_clicked() // Player 1
{
QString name(20, ' ');
QString score(4, ' ');
//Open text file
QFile file("Test.txt");
file.open(QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text);
QTextStream in(&file);
//Store score to string and make it 4 digits
QString line = ui->Player1Sel_A->currentText();
score = ui->lineEdit->text();
score.truncate(4);
//Search for string in UI, delete after
QString search(line);
QList<QListWidgetItem *> list = ui->listWidget->findItems(line, Qt::MatchContains);
for ( QListWidgetItem *item : list )
delete item;
//Temp store line string to another and delete data after ":"
name = line;
int pos = name.lastIndexOf(QChar(':'));
line = name.left(pos);
//New string and add name string with score and update UI
QStringList stringList;
stringList << line+':'+'\t'+'\t'+'\t'+score;
ui->listWidget->addItems(stringList);
//Update the text file from UI
auto numRows = ui->listWidget->count();
for(int row = 0; row < numRows; ++row)
{
auto item = ui->listWidget->item(row);
QString t;
t = item->text();
file.resize(0); // Deletes all data from the textfile
in<<t; //adds row to text file
in<<"\n"; //adds a line break
}
file.close();
}
void MainWindow::on_savescorep2_clicked() // Player 2
{
QString name(20, ' ');
QString score(4, ' ');
//Open text file
QFile file("Test.txt");
file.open(QIODevice::ReadWrite | QIODevice::Append | QIODevice::Text);