Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.6k Posts
  • Understanding warning "Returning data of temporary object"

    Solved
    4
    0 Votes
    4 Posts
    1k Views
    mrjjM
    @saa_ Hi Well it kinda depends on what we want to return. Sometimes we can get away with simply returning a copy. Like QString SomeFunc() then the Qstring does the copying for us. if we are talking a char * from a container like qbytearry the best way would be to allocated storage for it as docs shows. QString tmp = "test"; QByteArray text = tmp.toLocal8Bit(); char *data = new char[text.size() + 1]; strcpy(data, text.data()); and use that buffer. but that also places the burden on the caller to remember to deallocate the buffer. So when this i needed to do then using a smart pointer to hangle the char * buffer can be used. However, its not 100% the whole truth https://en.cppreference.com/w/cpp/language/lifetime (Temporary object lifetime) So you might get away with code belov as when part of the calling expressions, the compiler might keep it alive. char* qStringToCharPtr(QString string) { return string.toLocal8Bit().data(); }
  • Segmentation fault

    Solved
    11
    0 Votes
    11 Posts
    777 Views
    TequiloutreT
    OW FFS I hate myself. @jeremy_k were right. I'm a beginner with Qt and I've made a stupid mistake. I told myself "Hey you're creating pokemon_1 as a new pointer so you dynamicaly allocate some memory that have to be freeded at the end of the program haha" I had those lines at the end of my main_window class definition : delete pokemon_1; delete pokemon_2; OF COURSE they're destroyed before I press the button ! SO SORRY about that guys, thank you very much for your time and advices !
  • Aes encryption compatible with openssl cmd

    Solved
    14
    0 Votes
    14 Posts
    3k Views
    M
    @Christian-Ehrlicher Thanks man, this works for me ;) When I find some time I try to find bug in my code. Best Regards, Marek
  • libusb initialization crash

    Unsolved
    2
    0 Votes
    2 Posts
    356 Views
    Pablo J. RoginaP
    @SherifOmran you may need to improve your post, by providing more details. What compiler are you using? Did you download pre-built binaries from the libusb project? If so, are you sure they match the compiler you're using? Are you able to build and run the examples (non Qt apps) provided by the libusb project? Eventually, show the code snippet where you initialize the library
  • I can't find

    Unsolved
    5
    0 Votes
    5 Posts
    443 Views
    D
    @JonB thank you
  • Can someone help me fix this part of a recursive class

    Unsolved
    5
    0 Votes
    5 Posts
    427 Views
    JonBJ
    @AI_Messiah said in Can someone help me fix this part of a recursive class: I get some error message about the type it suggests const, but I add const and it doesn't help When asking for help, you are supposed to copy & paste the error message, which probably shows a line number, and show whatever you tried to resolve. Rather than leaving people to just guess.
  • Alexa with Qt Calendar

    Unsolved
    2
    0 Votes
    2 Posts
    219 Views
    JonBJ
    @Paras You would need to read up on Alexa documentation for this. I don't see anything in Qt which talks about integration with Alexa, other than possibly in Qt Automotive, which is a commercial offering anyway.
  • QScrollArea Not Expanding QCreate

    Solved
    10
    0 Votes
    10 Posts
    534 Views
    C
    @SGaist Sorry for the long reply, I was afk. What you said worked! Really need to watch those layouts, gotta set the QScrollArea to have a QWidget in it, that widget gets the main layout you want and it expands as you need.Thank you for your help and time!
  • fragmentation error when using Qtcpsocket write

    Unsolved
    3
    0 Votes
    3 Posts
    322 Views
    SGaistS
    Hi and welcome to devnet, From the looks of it you are expecting your client to receive all the data you sent in one go. That's not how tcp works. It's up to you cumulate the data you receive contains a full frame. You can use QDataStream and transactions.
  • [SOLVED] Convert #define value to QString?

    10
    0 Votes
    10 Posts
    11k Views
    SGaistS
    Hi, It would be simpler to use a generated header. The double quote escaping won't work on all platforms.
  • How to set enviorment variable from . pro file?

    Unsolved
    6
    0 Votes
    6 Posts
    517 Views
    Christian EhrlicherC
    Since you know when you run your tool with valgrind you can also set this env var before.
  • Associating a file type to my program?

    Unsolved
    15
    0 Votes
    15 Posts
    1k Views
    L
    @JonB I've been trying for 2 days but I couldn't get it to work: main.cpp int main(int argc, char *argv[]) { SingleApplication application( argc, argv, true); mainWindow = new MainWindow(); if (application.isSecondary()) { if (application.arguments().count() == 2) { application.sendMessage( argv[1] ); } return 0; } else { QObject::connect(&application, &SingleApplication::receivedMessage, mainWindow , &MainWindow::slotReceivedMessage); } mainwindow.cpp namespace Win32 { #include "Windows.h" } #define BUFSIZE 4096 void MainWindow::slotReceivedMessage(int instanceId, QByteArray message) { Win32::DWORD retval=0; Win32::BOOL success; Win32::TCHAR buffer[BUFSIZE]; Win32::TCHAR buf[BUFSIZE]; Win32::TCHAR** lppPart={NULL}; // convert char * to wchar_t * const size_t WCHARBUF = 100; wchar_t message_t[WCHARBUF]; Win32::MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, message, -1, message_t, WCHARBUF); // get full filename from short filename retval = Win32::GetFullPathName(message_t, BUFSIZE, buffer, lppPart); QString filePath = QString::fromWCharArray(buffer); qDebug() << message; qDebug() << filePath; } Since GetFullPathName needs a wchar_t as input, I have to first convert the char to wchar_t, then convert it to full path name. But when printing out with debug, both the input(message) and output(filePath) are still the same. The GetFullPathName wasn't doing anything. What am I doing wrong?
  • Error "Target xxx.obj does not exist" in pri

    Solved
    8
    0 Votes
    8 Posts
    765 Views
    Andy314A
    @Andy314 I tested a lot over hours to find out whats the problem. Creation of a new projekt or folder projekts gave the same error. Files with old filenames worked, new filenames worked no. The after some changing of "set xxx als active projekt" the Creator tried to compile (or was it reversed) a Cpp file with Python. This gave the hint that with the Creator is something wrong, the active project (resp. the file project relation) was no accepted correctly. Creating of a new workspace and integration my old project solved the problem. There must be a bug in the Creator.
  • QMainWindow: how to get a mouseReleaseEvent after resizing?

    Unsolved qmainwindow resizeevent
    4
    0 Votes
    4 Posts
    2k Views
    JonBJ
    @BwvB I don't know whether installing an eventFilter somewhere would see the mouse release. But I don't see the solutions mentioning that.
  • QProcess startDetached() run ps1 script

    Solved qprocess startdetached ps1 powershell script
    8
    0 Votes
    8 Posts
    2k Views
    P
    @SGaist Great idea! I change the code and everything should work. I close the topic and if I encounter any other problems I will create a new one. @SGaist , @JoeCFD Thank you for your help!
  • This topic is deleted!

    Unsolved
    2
    0 Votes
    2 Posts
    7 Views
  • How to show WiFi connections?

    Solved
    5
    0 Votes
    5 Posts
    1k Views
    S
    @jsulm I finally use a this code. Program in Windows and Raspberry PI do not show any things but in Ubuntu work! http://www.mediafire.com/file/7jrm90s1vsrs5m2/WiFi.rar/file
  • How to set QScatterSeries axis to draw between them?

    Unsolved
    5
    0 Votes
    5 Posts
    533 Views
    M.H.HM
    @JoeCFD Yes, it works. But it is not what I mentioned. To see my point try to add X-axis and Y-axis range wider than the point values.
  • QLineEdit: render whitespaces

    Unsolved
    6
    0 Votes
    6 Posts
    1k Views
    mrjjM
    @JonB Hi Yeah I missed first-time that user would also paste their credentials and to catch that one has to catch the context menu AND ctrl+v (or similar) and also prevent pressing space at the beginning. So we want them to be able to type spaces if in the middle of the user name but not in the front/end so I think calling trimmed before login will do the trick unless i missed something more :)
  • 0 Votes
    2 Posts
    618 Views
    JonBJ
    @Lian-ZhiYang As the error message invites you to do: "Press Retry to debug application". Whichever button that is, press it. Hopefully you will be taken into Visual Studio where you can view the stack trace to see if this emanates from a line in your code.