QFileDialog::getOpenFileName always returning null - qt

This is really stumping me, it was working before hand but now it always returns null (therefore not populating).
The code at question is:
imgObjPth = QFileDialog::getOpenFileName(this, tr("Select Image"), PATH);
imgObjPth is a QString variable, and QFileDialog returns QString. So how come it's returning null? As I said, this line of code has worked in the past, so I just don't know why today it decides not to work.
Edit:
Cancel is not being pressed.
I've moved my development from Mac to Ubuntu, but the same issue occurs on my Mac too.
QT 5.4.2 is used

Related

How to see return value in Qt Creator (gdb)

Is there a way to see the return value of a function in Qt Creator (in my case using GDB as the debugger)?
I found answer 3505002 (how to use gdb command list), but I was looking for something within the GUI if possible.
Here is the link to the closest answer found:
How to use gdb command list to print a function's parameter and return value without pausing?
One can see the return value by stepping out of the function (using the "Step Out" button or the F11 key in the Windows version of Creator) in the GUI.
Note that exiting the function by single stepping (using the Step Over button or F10 in the Windows version of Creator) does not provide the result.
When stepping out, the return value is shown in the Locals and Expressions View in a window that pops up between the stack variables and the expression evaluators.
It would be nice to always be able to see the return value of the most recently exited function, but it appears that gdb does not readily support it, so it may be unlikely that Creator will support it anytime soon. Anyway, using the Step Out feature anytime the return value is needed is a sufficient workaround.
#Felix Dombek:
At least on Linux step out is Shift-F11.
The return value will appear in an extra section of the variable explorer (available if you choose debug mode. Switch to debug mode by pressing the bug icon on the very left bar of Qt Creator or press Ctrl+4)
Screenshot:

Strange error with QListWidgetItem that uses QIcon

I am building up a QListWidget, browsing through a directory so that every ".png" gets listed with a preview icon.
The core of my populating loop looks like this:
new QListWidgetItem( QIcon(act_fullname), act_filename);
Right after the whole list is ready, the app crashes.
The error is many times repeated and says this:
On Mac OS X, you might be loading two sets of Qt binaries into the
same process. Check that all plugins are compiled against the right Qt
binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of
binaries are being loaded. QObject::moveToThread: Current thread
(0x103339cb0) is not the object's thread (0x10a848670). Cannot move to
target thread (0x103339cb0)
On Mac OS X, you might be loading two sets of Qt binaries into the
same process. Check that all plugins are compiled against the right Qt
binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of
binaries are being loaded.
Do you have any ideas?
Thanks for your help!
EDIT:
If I skip the icons there is no problem. I have also tried going
QListWidgetItem *item = new QListWidgetItem(act_filename);
ui->listWidget->addItem(item);
item->setIcon(QIcon(act_fullname));
and got no difference.
EDIT 2:
I do not call QObject::moveToThread(QThread*) I don't even use threads (deliberately at least).
Also, the errors appear to come after the loop. I have cout-ed every iteration and the end of the loop and right after my "end loop cout msg" I see that
objc[56963]: Class QCocoaColorPanelDelegate is implemented in both
/Users/Barnabas/QtSDK/Desktop/Qt/4.8.1/gcc/lib/QtGui.framework/Versions/4/QtGui
and
/Users/Barnabas/Programming/Qt/demo_OpenCV-build-desktop-Desktop_Qt_4_8_1_for_GCC__Qt_SDK__Release/demo_OpenCV.app/Contents/MacOS/../Frameworks/QtGui.framework/Versions/4/QtGui.
One of the two will be used. Which one is undefined.
Here, too, I do not use QCocoaColorPanelDelegate. I don't even know what it is ... :(
But here is my more detailed code:
boost::filesystem::path p("/path/to/dir");
if(boost::filesystem::is_directory(p))
{
for(boost::filesystem::directory_iterator it(p); it!=boost::filesystem::directory_iterator(); ++it)
{
if(it->path().extension().string()==".png")
{
std::cout<< it->path() <<std::endl;
QString item_name( it->path.stem().c_str() );
QString screen_file( it->path.c_str() );
QListWidgetItem *item = new QListWidgetItem(item_name);
QIcon *icon = new QIcon(screen_file);
item->setIcon(*icon); // if I comment this one out, everything is fine.
ui->imageList->addItem(item);
}
}
}
I have also tested it with a single .png and the image was displayed properly in the list but crash followed with the very same messages.
I have finally found the solution: manually removed the Debug and the Release directories.
For those whose similar problem is not solved by this see: this link.

QFileDialog encoding error (Windows 7)

When i try to use standart filechooser:
QString fileName = QFileDialog::getOpenFileName(a.allWidgets().first(),
"Open Image", "C:\\", "Image Files (*.png *.jpg *.bmp)");
the error is appear. I see the message, like this (sorry, it's in russian):
the translation of first line is "C:\Users\Василий\Desctop references an inaccessible location". I think, that problem in user-name "Василий" (russian letters), which not clearly written on screenshot. I have tried to find in Google the solving of my problem, but unfortunately, I haven't find. Help please.
Recently I've faced the same problem. It seems like some bug in Qt, which causes this error, when the name of your home folder contains non-latin symbols.
Remarkable that if you run your application in Release mode, it will work fine. I hope this information will be useful for somebody.

New in 4.7.4: QDir::homePath() gives out empty string

QString path = QDir::homePath(); // <-- "path" is always ""
Is this a new bug in 4.7.4? use to work well in 4.7.3
I’m on OSX Lion (4.7.3 worked on Lion well).
The “Clear System Environment” probably cleared the HOME environment variable too.
Basically, QDir::homePath() returns QFile::decodeName(QByteArray(::getenv("HOME"))) almost unchecked. And that's an empty string, if there is no HOME variable.
Hmmm It seems the problem is resolved if I don’t use the “Clear System Environment”. I unchecked it, then re-built and it worked fine. could it be the “SHELL” definitions? I can’t think of anything other than that that’s remotely related to this. I guess something caused Qt to have QT_NO_FSFILEENGINE defined and thus to return an empty string:
// from Qt source file: QDir.cpp
QString QDirPrivate()
{
#ifdef QT_NO_FSFILEENGINE
return QString();
#else
return cleanPath(QFSFileEngine::homePath());
#endif
}

browseForOpenMultiple - crashing

I am trying to work with browseForOpenMultiple function inside Flex, sdk 3.5, I am trying to figure out a bug. The browseForOpenMultiple does not crash everytime, but it seems as though I can upload a file once, but when I go to upload a second file, it crashes when the browseForOpenMultiple function is called. Anyone have any ideas about possible causes?
Update:
private function browseForFiles():void
{
fileBrowser = new File();
fileBrowser.addEventListener(FileListEvent.SELECT_MULTIPLE, filesSelected);
fileBrowser.addEventListener(Event.CANCEL, fileSelectionCancelled);
fileBrowser.browseForOpenMultiple("Select Desired Media File(s)", [(mode == "Media")? MediaTypes.getFileFilter() : MediaTypes.getVideoFilter()]);
}
So the code in our array of file extensions was crashing when there were over 60 items listed in an array that gets converted into a string for the FileFilter. This may not be an Adobe limit, but I wanted to make mention that the crash is fixed, so that others who may be encountering issues with browseForOpenMultiple will know what the issue was for this problem. This is not code that I originally wrote, so I will check into it for more clues, but for the time being, too many array items being joined together into a string for FileFilter object caused the crash.
It could be how it's construct the File, without a real file reference.
Try something like this :
var fileBrowser = File.desktopDirectory

Resources