show items value in memo - c++

C++ Builder XE8
if i select Num 1 Memo will show Test
if i select other items memo will show Else Test
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ListBox1->Items->Add("Num 1");
ListBox1->Items->Add("Num 2");
ListBox1->Items->Add("Num 3");
auto str = listBox1->SelectedItem->ToString();
if (str == L"Num 1") {
Memo1->Text = "Test";
}
else {
Memo1->Text = "Else Test";
}
}

The Form's OnCreate event (which you SHOULD NOT be using in C++, use the Form's constructor instead) is too soon to detect the user's selection, as the user has not had a chance to see the UI yet to select anything. Use the ListBox's OnChange event instead.
Also, TListBox does not have a SelectedItem property. In FireMonkey (which I assume you are using instead of VCL), it has a Selected property instead.
Try this:
__fastcall TForm1::TForm1(TComponent *Owner)
: TForm(Owner)
{
ListBox1->BeginUpdate();
try {
ListBox1->Items->Add("Num 1");
ListBox1->Items->Add("Num 2");
ListBox1->Items->Add("Num 3");
}
__finally {
ListBox1->EndUpdate();
}
}
void __fastcall TForm1::ListBox1Change(TObject *Sender)
{
TListBoxItem *Item = ListBox1->Selected;
if (Item) {
String str = ListBox1->Selected->Text;
if (str == L"Num 1") {
Memo1->Text = "Test";
}
else {
Memo1->Text = "Else Test";
}
}
else {
Memo1->Text = "Nothing";
}
}

Related

new list show up in RecyclerView after item deleted

I got an issue when I tried to remove an item in a list. when I tried to remove a list it disappeared, but they show a new list. the case looks like this.
below I provided my code also
adapter.setOnItemClickedCallback(object : ListOrderAdapter.OnItemClickCallback {
override fun onDecrementButtonClicked(orderMenu: OrderMenu, itemView: View, position: Int) {
var quantityChanged = (orderMenu.quantity)!!.minus(1)
itemView.tv_order_number.text = quantityChanged.toString()
Log.e("Position", position.toString())
if (quantityChanged > 0) {
updateData(quantityChanged, orderMenu)
} else {
listItem.remove(orderMenu)
recyclerView.removeViewAt(position)
adapter.notifyItemRemoved(position)
adapter.notifyItemRangeRemoved(position, listItem.size)
Toast.makeText(applicationContext, "Pesanan telah di hapus dari orderan", Toast.LENGTH_SHORT).show()
}
}
})
}
private fun updateData(quantityChanged: Long, orderMenu: OrderMenu) {
for (item in listItem){
if (item.name.equals(orderMenu.name)){
item.quantity = quantityChanged
}
}
}

contextual action mode only works for one time

i did a contextual action mode and it is working very well when i click on the options that i created but the problem is it the action mode only works for one time and to enable it again i have exit the app and run it again
here's my code
Button.setOnLongClickListener(new View.OnLongClickListener() {
#Override
public boolean onLongClick(View v) {
if (actionMode != null) {
return false;
}
actionMode = startActionMode(startActionMode);
return true;
}
});
}
private ActionMode.Callback startActionMode = new ActionMode.Callback() {
#Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
mode.getMenuInflater().inflate(R.menu.menu12, menu);
mode.setTitle("choose your option");
return true;
}
#Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
#Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
switch (item.getItemId()) {
case R.id.item1:
Toast.makeText(MainActivity.this, "item 1 pressed", Toast.LENGTH_SHORT).show();
mode.finish();
return true;
case R.id.item2:
Toast.makeText(MainActivity.this, "item 2 pressed", Toast.LENGTH_SHORT).show();
mode.finish();
return true;
default:
return false;
}
}
#Override
public void onDestroyActionMode(ActionMode mode) {
startActionMode = null;
}
};
}
Simply instead of
startActionMode = null;
use
actionMode = null;

ViewPager not working in Google Glass after XE16 update

My Glass got updated to XE16 and thereafter Viewpagers used in Glassware is not working. It is not possible to move to any of the pagers by swiping.If anybody has encountered this before,please do help.
Thanks
Heh. Yeah, the update removed certain standard things from happening (like gestures on the touchpad moving focus etc).
What you have to do is implement a gesturerecogniser/listener and implement the necessary fields, like so (don't forget to instantiate/implement/import etc etc etc in the activity)):
private GestureDetector createGestureDetector(Context context) {
GestureDetector gestureDetector = new GestureDetector(context);
//Create a base listener for generic gestures
gestureDetector.setBaseListener( new GestureDetector.BaseListener() {
#Override
public boolean onGesture(Gesture gesture) {
if (gesture == Gesture.TAP) {
// do something on tap
//do ?
return false;
} else if (gesture == Gesture.TWO_TAP) {
// do something on two finger tap
return true;
} else if (gesture == Gesture.LONG_PRESS) {
// do something on long press
if (!showingMenu)
{
openOptionsMenu();
return true;
}
else
{
return false;
}
} else if (gesture == Gesture.SWIPE_RIGHT) {
// do something on right (forward) swipe
//next slide:
mPosition++;
if (mPosition >= cardArray.size())
{
mPosition = cardArray.size() -1;
}
mGallery.setSelection(mPosition);
return true;
} else if (gesture == Gesture.SWIPE_LEFT) {
// do something on left (backwards) swipe
//previous slide:
mPosition--;
if (mPosition < 0)
{
mPosition = 0;
}
mGallery.setSelection(mPosition);
return true;
}
return false;
}
});
gestureDetector.setFingerListener(new GestureDetector.FingerListener() {
#Override
public void onFingerCountChanged(int previousCount, int currentCount) {
// do something on finger count changes
}
});
/*gestureDetector.setScrollListener(new GestureDetector.ScrollListener() {
#Override
public boolean onScroll(float displacement, float delta, float velocity) {
// do something on scrolling
if (delta > 5.0f)
{
//scroll forwards:
//
}
else if (delta < -5.0f)
{
//scroll backwards:
//
}
return false;
}
});*/
return gestureDetector;
}
/*
* Send generic motion events to the gesture detector
*/
#Override
public boolean onGenericMotionEvent(MotionEvent event) {
if (mGestureDetector != null) {
return mGestureDetector.onMotionEvent(event);
}
return false;
}
I replaced my Viewpager with CardScrollView and it is pretty fast as well.
Do try that out.

Contact Picker Code

i need some help with a contacts picker class that ive got.
The class retrieves the contacts list and allows me to choose one, but when I go and choose another one, it just replaces the first one.
I want to make a list of contacts in my app and not only one.
Thank you,
Noam
The Code:
public static final int PICK_CONTACT = 1;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
Button btnPickContact = (Button) findViewById(R.id.btnPickContact);
btnPickContact.setOnClickListener(new OnClickListener() {
public void onClick(View _view) {
Intent intent = new Intent(Intent.ACTION_PICK,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
}
});
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case (PICK_CONTACT): {
if (resultCode == Activity.RESULT_OK) {
Uri contentUri = data.getData();
//Phone Name
Cursor c = managedQuery(contentUri, null, null, null, null);
c.moveToFirst();
String name = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
//Phone Number
String contactId = contentUri.getLastPathSegment();
Cursor cursor = getContentResolver().query(Phone.CONTENT_URI,
null, Phone._ID + "=?", new String[] { contactId },
null);// < - Note, not CONTACT_ID!
startManagingCursor(cursor);
Boolean numbersExist = cursor.moveToFirst();
int phoneNumberColumnIndex = cursor
.getColumnIndex(Phone.NUMBER);
String phoneNumber = "";
while (numbersExist) {
phoneNumber = cursor.getString(phoneNumberColumnIndex);
phoneNumber = phoneNumber.trim();
numbersExist = cursor.moveToNext();
}
stopManagingCursor(cursor);
//Set
TextView tv = (TextView) findViewById(R.id.txtSelContact);
tv.setText(name + "-" + phoneNumber);
}
break;
}
}
}
}
And here is the on create function:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
Button btnPickContact = (Button) findViewById(R.id.btnPickContact);
btnPickContact.setOnClickListener(new View.OnClickListener() {
public void onClick(View _view) {
Intent intent = new Intent(Intent.ACTION_PICK,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
}
});
//you may fill it here e.g. from your db
contactList=new ArrayList<String>();
arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, contactList);
final ListView lv = (ListView) findViewById(R.id.ContactListView);
lv.setAdapter(arrayAdapter);
}
This is the layout.xml (for some reason it didn't let me post the code so i linked to an image) :
https://imagizer.imageshack.us/v2/516x255q90/4/igi5.png
Lines 29 - 35:
btnPickContact.setOnClickListener(new View.OnClickListener() {
public void onClick(View _view) {
Intent intent = new Intent(Intent.ACTION_PICK,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
}
});
as far as I see you are writing results into the same textview:
//Set
TextView tv = (TextView) findViewById(R.id.txtSelContact);
tv.setText(name + "-" + phoneNumber);
You could specify a Listview in your Layout
<ListView
android:id="#+id/ContactListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
and use an arrayadapter to add your result to this Listview:
public class MainActivity extends Activity {
public static final int PICK_CONTACT = 1;
private ArrayList<String> contactList;
private ArrayAdapter<String> arrayAdapter;
#Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_main);
Button btnPickContact = (Button) findViewById(R.id.btnPickContact);
btnPickContact.setOnClickListener(new View.OnClickListener() {
public void onClick(View _view) {
Intent intent = new Intent(Intent.ACTION_PICK,
ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
}
});
//you may fill it here e.g. from your db
contactList=new ArrayList<String>();
arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, contactList);
final ListView lv = (ListView) findViewById(R.id.contactListView);
lv.setAdapter(arrayAdapter);
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case (PICK_CONTACT): {
if (resultCode == Activity.RESULT_OK) {
Uri contentUri = data.getData();
//Phone Name
Cursor c = managedQuery(contentUri, null, null, null, null);
c.moveToFirst();
String name = c.getString(c.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
//Phone Number
String contactId = contentUri.getLastPathSegment();
Cursor cursor = getContentResolver().query(Phone.CONTENT_URI,
null, Phone._ID + "=?", new String[] { contactId },
null);// < - Note, not CONTACT_ID!
startManagingCursor(cursor);
Boolean numbersExist = cursor.moveToFirst();
int phoneNumberColumnIndex = cursor
.getColumnIndex(Phone.NUMBER);
String phoneNumber = "";
while (numbersExist) {
phoneNumber = cursor.getString(phoneNumberColumnIndex);
phoneNumber = phoneNumber.trim();
numbersExist = cursor.moveToNext();
}
stopManagingCursor(cursor);
//Set
arrayAdapter.add(name + "-" + phoneNumber);
arrayAdapter.notifyDataSetChanged();
}
break;
}
}
}
}

navigate page after parsing in BB 10

I am try to navigate page after parsing but before i got response from server, method getLoginData() is called from Qml file and get false because at the time of calling this function response not get from server, when i click again in button where this function is call, i got accurate result because this time i already got the result. so please help me to solve it out.......
My code...
[B]main.qml[/B]
enter code here
// Navigation pane project template
import bb.cascades 1.0
import bb.system 1.0
NavigationPane {
id: navigationPane
objectName: "navigationPaneQml"
Page {
id: loginPage
objectName : "pageQml"
Container {
id: container1
background: Color.Green
leftPadding: 10
rightPadding: 10
topPadding: 10
layout: StackLayout {
orientation:LayoutOrientation.TopToBottom
}
TextField {
id: usernameBox
objectName: "textFieldRetrived"
hintText: "Enter Your Mobile Number"
topPadding: 10
inputMode: TextFieldInputMode.PhoneNumber
preferredWidth: maxWidth
input {
flags: TextInputFlag.PredictionOff |
TextInputFlag.AutoCorrectionOff
}
// validator: IntValidator {
// bottom: 0
// top: 9999999999
// }
validator: Validator {
mode: ValidationMode.Immediate
errorMessage: "Your username must be 10 characters."
onValidate: {
if (usernameBox.text.length < 10 || usernameBox.text.length > 10) state = ValidationState.Invalid;
else state = ValidationState.Valid;
}
}
// validator: RegExpValidator {
// mode: ValidationMode.Immediate
// regExp: /\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*/
// onValidate: {
// if (usernameBox.text.length <= 10) state = ValidationState.Valid;
// else state = ValidationState.Invalid;
// }
// }
}
Button {
id: submitButton
objectName : submitButtonQml
horizontalAlignment: HorizontalAlignment.Center
// verticalAlignment: VerticalAlignment.Center
text: qsTr("Submit")
preferredWidth: minWidth
// imageSource: "asset:///images/picture1thumb.png"
attachedObjects: [
SystemToast {
id: invalidUsername
body: "Invalid Username"
onFinished: {
// Application.quit();
}
},
SystemToast {
id: networkNotAvalable
body: "Network not Avalable"
onFinished: {
// Application.quit();
}
},
SystemToast {
id: invalidToast
body: "Not a valid input"
onFinished: {
// Application.quit();
}
},
ComponentDefinition {
id: pageDefinition
source: "splash.qml"
}
]
onClicked: {
if(usernameBox.text!= null && usernameBox.text!=""){
if(app.isNetworkAvailable()){
app.initiateRequest(usernameBox.text)
if (app.getLoginData() == "True"){
var newPage = pageDefinition.createObject();
navigationPane.push(newPage);
}else{
invalidUsername.show()
}
}else {
networkNotAvalable.show()
}
}else{
invalidToast.show()
}
}
}
TextArea {
id: chat
objectName: "textArea"
inputMode: TextAreaInputMode.Default
}
Container {
id: cntrUpdates
horizontalAlignment: HorizontalAlignment.Center
// verticalAlignment: VerticalAlignment.Top
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
preferredWidth: 1280.0
leftPadding: 90.0
topPadding: 20.0
Label {
objectName: "lblRetrieve"
text: "Retrieving contact list ..."
textStyle.textAlign: TextAlign.Right
verticalAlignment: VerticalAlignment.Center
}
// The activity indicator has an object name set so that
// we can start and stop it from C++ code.
ActivityIndicator {
objectName: "indicator"
running: false
}
}
}
}
onCreationCompleted: {
// this slot is called when declarative scene is created
// write post creation initialization here
console.log("NavigationPane - onCreationCompleted()");
// enable layout to adapt to the device rotation
// don't forget to enable screen rotation in bar-bescriptor.xml (Application->Orientation->Auto-orient)
OrientationSupport.supportedDisplayOrientation = SupportedDisplayOrientation.All;
}
}
[B]DemoProject2.cpp[/B]
// Navigation pane project template
#include "DemoProject2.hpp"
#include <bb/cascades/Application>
#include <bb/cascades/QmlDocument>
#include <bb/cascades/AbstractPane>
#include <QIODevice>
#include <bb/cascades/XmlDataModel>
#include <bb/cascades/Color>
#include <bps/bps.h>
#include <bps/netstatus.h>
#include <bps/locale.h>
#include <QXmlStreamReader>
#include <QFile>
#include <QDir>
#include <QDebug>
#include <iostream>
#include <QtCore/QCoreApplication>
#include <QTextStream>
#include <QDomDocument>
#include <QDomNodeList>
#include <QtXml/qxml.h>
#include <QString>
#include <bb/cascades/ValidationMode>
#include <bb/cascades/Validator>
#include <bb/system/SystemToast>
#include <bb/system/SystemUiPosition>
#include <QtCore/QDebug>
using namespace bb::cascades;
using namespace bb::system;
DemoProject2::DemoProject2(bb::cascades::Application *app)
: QObject(app)
{
// create scene document from main.qml asset
// set parent to created document to ensure it exists for the whole application lifetime
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
// Expose this class to QML so that we can call it's functions from C++ code.
qml->setContextProperty("app", this);
// create root object for the UI
AbstractPane *root = qml->createRootObject<AbstractPane>();
// set created root object as a scene
// Retrieve the activity indicator from QML so that we can start
// and stop it from C++ code.
myActivityIndicator = root->findChild<ActivityIndicator*>("indicator");
myTextField = root->findChild<TextField*>("textFieldRetrived");
myLabel = root->findChild<Label*>("lblRetrieve");
textArea = root->findChild<TextArea*>("textArea");
submitButton = root->findChild<Button*>("submitButtonQml");
// navigationPane = root->findChild<NavigationPane*>("navigationPaneQml");
// root = qml->createRootObject<NavigationPane>();
// QmlDocument *qml1 = QmlDocument::create("asset:///splash.qml").parent(this);
//// mNewPage = new Page();
// mNewPage = qml1->createRootObject<Page>();
myNetworkAccessManager = new QNetworkAccessManager(this);
connect(myNetworkAccessManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(requestFinished(QNetworkReply*)));
// Create a file in the file system that we can use to save the data model.
myFile = new QFile("data/model.xml");
app->setScene(root);
}
bool DemoProject2::isNetworkAvailable() {
QNetworkConfigurationManager netMgr;
QList<QNetworkConfiguration> mNetList = netMgr.allConfigurations(
QNetworkConfiguration::Active);
if (mNetList.count() > 0) {
if (netMgr.isOnline()) {
return true;
} else {
return false;
}
} else {
return false;
}
}
void DemoProject2::initiateRequest(QString text){
text.trimmed();
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","hhhh");
isComplete = false;
// Start the activity indicator.
myActivityIndicator->start();
myLabel->setVisible(true);
myLabel->setText("Retrieving contact list ...");
// Create and send the network request.
QNetworkRequest request = QNetworkRequest();
request.setUrl(QUrl("******************"));
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","00");
myNetworkAccessManager->get(request);
}
void DemoProject2::requestFinished(QNetworkReply* reply){
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","NUM 0");
myActivityIndicator->stop();
myLabel->setVisible(false);
// Check the network reply for errors.
if (reply->error() == QNetworkReply::NoError){
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","NUM 1");
/****** Sax Parsing code Section..................******/
QByteArray data = reply->readAll();
xmlSaxParser(data);
/****** dom parsing code section ........******/
// QByteArray byteArray = reply->readAll();
// xmlDomParser(byteArray);
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","NUM 2");
reply->deleteLater();
}
}
bool DemoProject2:: getCompleteVariable(){
return isComplete;
}
void DemoProject2 :: setLoginData(QString data){
loginData = data;
}
QString DemoProject2 :: getLoginData(){
while(!getCompleteVariable()){
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","shivang");
}
return loginData;
}
void DemoProject2:: xmlSaxParser(QByteArray data){
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","NUM 3");
// The XML stream reader that is used to extract the articles from the RSS feed
QXmlStreamReader m_xml;
m_xml.addData(data);
QString currentTag = "";
QString linkString;
QString titleString;
while (!m_xml.atEnd())
{
m_xml.readNext();
if (m_xml.isStartElement())
{
if (m_xml.name() == "contacts"){
linkString = m_xml.attributes().value("title").toString();
currentTag = m_xml.name().toString();
myLabel->setVisible(true);
myLabel->setText(linkString);
}else if(m_xml.name() == "return"){
currentTag = m_xml.name().toString();
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","ns:return");
}
}
else if (m_xml.isEndElement())
{
if (m_xml.name() == "return")
{
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","return");
// linkString = m_xml.attributes().value("rss:about").toString();
titleString.clear();
// linkString.clear();
}
} else if (m_xml.isCharacters() && !m_xml.isWhitespace())
{
if (currentTag == "return"){
titleString += m_xml.text().toString();
myLabel->setVisible(true);
myLabel->setText(titleString);
setLoginData(titleString);
// textArea->setText(titleString);
// currentTag = "";
}
}
}
if (m_xml.error() && m_xml.error() != QXmlStreamReader::PrematureEndOfDocumentError) {
// m_feeds.append(
// QString::fromLatin1("XML ERROR: %1: %2").arg(m_xml.lineNumber()).arg(m_xml.errorString()));
}
fprintf(stderr, "Debug::::::::::::::::::::::::::: %s\n","NUM 4");
// navigationPane->push(mNewPage);
isComplete = true;
}
[B]DemoProject2.hpp[/B]
// Navigation pane project template
#ifndef DemoProject2_HPP_
#define DemoProject2_HPP_
#include <QObject>
#include <QFile>
#include <QString>
#include <bb/cascades/ActivityIndicator>
#include <bb/cascades/TextField>
#include <bb/AbstractBpsEventHandler>
#include <bb/cascades/Application>
#include <bb/cascades/Label>
#include <bb/cascades/TextArea>
#include <bb/cascades/Button>
#include <bb/cascades/NavigationPane>
#include <bb/cascades/Page>
using namespace bb::cascades;
namespace bb { namespace cascades { class Application; }}
/*!
* #brief Application pane object
*
*Use this object to create and init app UI, to create context objects, to register the new meta types etc.
*/
class DemoProject2 : public QObject
{
Q_OBJECT
public:
DemoProject2(bb::cascades::Application *app);
virtual ~DemoProject2() {}
// void parseXml (QByteArray data);
Q_INVOKABLE void initiateRequest(QString text);
Q_INVOKABLE bool isNetworkAvailable();
Q_INVOKABLE void xmlSaxParser(QByteArray data);
Q_INVOKABLE void xmlDomParser(QByteArray data);
Q_INVOKABLE QString getLoginData();
Q_INVOKABLE void setLoginData(QString data);
Q_INVOKABLE bool getCompleteVariable();
// NavigationPane *root;
// signals:
// void networkStatusUpdated(bool status, QString type);
private slots:
void requestFinished(QNetworkReply* reply);
// void networkStatusUpdateHandler(bool status, QString type);
private:
bb::cascades::TextField *myTextField;
bb::cascades::ActivityIndicator *myActivityIndicator;
bb::cascades::Label *myLabel;
bb::cascades::TextArea *textArea;
bb::cascades::Button *submitButton;
// bb::cascades::NavigationPane* navigationPane;
// bb::cascades:: Page* mNewPage;
QNetworkAccessManager *myNetworkAccessManager;
QFile *myFile;
QString loginData;
QByteArray data;
bool isComplete;
// Page* mNewPage;
// StatusEvent *statusEvent;
};
#endif /* DemoProject2_HPP_ */
use event loop....
QNetworkAccessManager* netManager = new QNetworkAccessManager();
QUrl myurl("http://******");
QNetworkRequest req(myurl);
QNetworkReply* ipReply = netManager->get(req);
QEventLoop eventLoop;
QObject::connect(ipReply, SIGNAL(finished()), &eventLoop, SLOT(quit()));
eventLoop.exec();
std::cout << "finished" << std::endl; //request finished here
requestFinished(ipReply);