I mean to use QString instead of std::string all over the place (so that you don't need to convert strings)
I mean to use QString instead of std::string all over the place (so that you don't need to convert strings)
Yeah I could do that, but then I have to change every single std::string to a QString and I'm almost sure that something will f*** up in the process.
You think thats the easiest way? easier than only to have a function that converts all strings to QStrings?
Well it is easier with conversion, but conversion means a copy of the string and if you have a lot of strings, and that lot increases, at some point that conversion might not be acceptable any more.
But if your number of conversions is low the performance penalty is also low.
//but for a new project you can use QString from the beginning and see that QString has many more features than std::string, so it may be easier to use.
ok, thanks for the tip.
What do you think about the function I posted above? Is that conversion working? and what can I write inside that function if I want all the data to be presented in a window.
I mean if I wanted to do that in VS I would only write cout but what about now?
You can still use cout to print QString to console with the help of qPrintable or you can use qstringName.toLocal8Bit().constData();
Or you can use qDebug()
But if I dont want to print it in the console? I want it to be printed out in the QListWidget.
Then use addItem(...)
I have these two
Qt Code:
private: Ui::MainWindow *ui; QLineEdit *line1; QListWidget *list1;To copy to clipboard, switch view to plain text mode
and these two functions
Qt Code:
void MainWindow::on_lineEdit_2_returnPressed() { on_listWidget_activated(line1->text()); } { list1->addItem(index); }To copy to clipboard, switch view to plain text mode
but when I run it and type into the lineEdit and push enter nothing happens![]()
Why don't you do yourself and every one else a favor and start with reading some documentation.
I think you might want to start with the Qt basics like signals and slots.
yeah I understand that but I think that the thing I want to accomplish is not that complicated, so I just need a push in the right direction.
If I know how to catch data from a line and present some data in a window then I think I can figure out everything else by my self cos I believe its just basic c++ after that.
Bookmarks