Hi everybody,
I created a reminder app that plays some mp3 files at specific times using QMediaPlayer an QMediaPlaylist. Those files are loaded in the playlist using relative paths. I added also the possibility to lunch the app by command line arguments at windows startup.
the problem is when the app is lunched at startup ( HKLM\...\Run) the mp3 files are not loaded in the playlist BUT when i add the app .exe shortcut with the same command line arguments to the startup folder (AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup) mp3 files are loaded and everything is OK...
Thanks for your help 
More informations:
directory structure:
struct.png
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
mainwindow w;
if (a.arguments().count() > 1)
{
QString arg1
= a.
arguments().
at(1);
{
w.startUp();
}
}
else
w.show();
return a.exec();
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
mainwindow w;
if (a.arguments().count() > 1)
{
QString arg1 = a.arguments().at(1);
if(arg1==QString("/boot"))
{
w.startUp();
}
}
else
w.show();
return a.exec();
To copy to clipboard, switch view to plain text mode
loading files into playList:
{...}
player = new QMediaPlayer(this);
playList = new QMediaPlaylist();
playList
->addMedia
(QUrl::fromLocalFile("media/sound.mp3"));
playList
->addMedia
(QUrl::fromLocalFile("media/reminder.mp3"));
playList->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
player->setPlaylist(playList);
{...}
{...}
player = new QMediaPlayer(this);
playList = new QMediaPlaylist();
playList->addMedia(QUrl::fromLocalFile("media/sound.mp3"));
playList->addMedia(QUrl::fromLocalFile("media/reminder.mp3"));
playList->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
player->setPlaylist(playList);
{...}
To copy to clipboard, switch view to plain text mode
startup function:
void mainwindow::startUp()
{
this->showMinimized();
this->hide();
trayIcon->show();
}
void mainwindow::startUp()
{
this->showMinimized();
this->hide();
trayIcon->show();
}
To copy to clipboard, switch view to plain text mode
Added after 1 47 minutes:
Ok i solved the problem by using QCoreApplication::applicationDirPath () because when my app is started with windows the working directory changes to SysWOW64.
Bookmarks